Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #14168 from vickramdhawal/vdhawal-upstream/updatin…
Browse files Browse the repository at this point in the history
…gImmutableJS

Bringing in ImmutableJS 3.8.2
  • Loading branch information
swmitra authored Mar 23, 2018
2 parents d0213b2 + 1245efb commit 43cfabb
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 77 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ package-lock.json

# ignore node_modules inside src
/src/node_modules
/src/JSUtils/node_modules
/src/JSUtils/node/node_modules

# ignore files copied from node_modules to src/thirdparty
/src/thirdparty/CodeMirror
Expand Down
149 changes: 72 additions & 77 deletions src/thirdparty/immutable.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* 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) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
global.Immutable = factory();
(global.Immutable = factory());
}(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice;

function createClass(ctor, superClass) {
Expand Down Expand Up @@ -905,7 +903,7 @@
}
return 'Range [ ' +
this._start + '...' + this._end +
(this._step > 1 ? ' by ' + this._step : '') +
(this._step !== 1 ? ' by ' + this._step : '') +
' ]';
};

Expand Down Expand Up @@ -1037,6 +1035,9 @@
}
var type = typeof o;
if (type === 'number') {
if (o !== o || o === Infinity) {
return 0;
}
var h = o | 0;
if (h !== o) {
h ^= o * 0xFFFFFFFF;
Expand Down Expand Up @@ -1222,6 +1223,17 @@
});
}

Map.of = function() {var keyValues = SLICE$0.call(arguments, 0);
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() {
return this.__toString('Map {', '}');
};
Expand Down Expand Up @@ -3134,7 +3146,11 @@
begin = begin | 0;
}
if (end !== undefined) {
end = end | 0;
if (end === Infinity) {
end = originalSize;
} else {
end = end | 0;
}
}

if (wholeSlice(begin, end, originalSize)) {
Expand Down Expand Up @@ -3671,6 +3687,12 @@
if (!this.has(k)) {
throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
}
if (this._map && !this._map.has(k)) {
var defaultVal = this._defaultValues[k];
if (v === defaultVal) {
return this;
}
}
var newMap = this._map && this._map.set(k, v);
if (this.__ownerID || newMap === this._map) {
return this;
Expand Down Expand Up @@ -4354,21 +4376,6 @@
return entry ? entry[1] : notSetValue;
},

findEntry: function(predicate, context) {
var found;
this.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
found = [k, v];
return false;
}
});
return found;
},

findLastEntry: function(predicate, context) {
return this.toSeq().reverse().findEntry(predicate, context);
},

forEach: function(sideEffect, context) {
assertNotInfinite(this.size);
return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
Expand Down Expand Up @@ -4479,10 +4486,34 @@
return this.filter(not(predicate), context);
},

findEntry: function(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(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry && entry[0];
},

findLast: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
},

findLastEntry: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().findEntry(predicate, context, notSetValue);
},

findLastKey: function(predicate, context) {
return this.toKeyedSeq().reverse().findKey(predicate, context);
},

first: function() {
return this.find(returnTrue);
},
Expand Down Expand Up @@ -4541,6 +4572,10 @@
return iter.isSubset(this);
},

keyOf: function(searchValue) {
return this.findKey(function(value ) {return is(value, searchValue)});
},

keySeq: function() {
return this.toSeq().map(keyMapper).toIndexedSeq();
},
Expand All @@ -4549,6 +4584,10 @@
return this.toSeq().reverse().first();
},

lastKeyOf: function(searchValue) {
return this.toKeyedSeq().reverse().keyOf(searchValue);
},

max: function(comparator) {
return maxFactory(this, comparator);
},
Expand Down Expand Up @@ -4639,35 +4678,6 @@
IterablePrototype.chain = IterablePrototype.flatMap;
IterablePrototype.contains = IterablePrototype.includes;

// Temporary warning about using length
(function () {
try {
Object.defineProperty(IterablePrototype, 'length', {
get: function () {
if (!Iterable.noLengthWarning) {
var stack;
try {
throw new Error();
} catch (error) {
stack = error.stack;
}
if (stack.indexOf('_wrapObject') === -1) {
console && console.warn && console.warn(
'iterable.length has been deprecated, '+
'use iterable.size or iterable.count(). '+
'This warning will become a silent error in a future version. ' +
stack
);
return this.size;
}
}
}
});
} catch (e) {}
})();



mixin(KeyedIterable, {

// ### More sequential methods
Expand All @@ -4676,23 +4686,6 @@
return reify(this, flipFactory(this));
},

findKey: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry && entry[0];
},

findLastKey: function(predicate, context) {
return this.toSeq().reverse().findKey(predicate, context);
},

keyOf: function(searchValue) {
return this.findKey(function(value ) {return is(value, searchValue)});
},

lastKeyOf: function(searchValue) {
return this.findLastKey(function(value ) {return is(value, searchValue)});
},

mapEntries: function(mapper, context) {var this$0 = this;
var iterations = 0;
return reify(this,
Expand Down Expand Up @@ -4741,16 +4734,13 @@
},

indexOf: function(searchValue) {
var key = this.toKeyedSeq().keyOf(searchValue);
var key = this.keyOf(searchValue);
return key === undefined ? -1 : key;
},

lastIndexOf: function(searchValue) {
var key = this.toKeyedSeq().reverse().keyOf(searchValue);
var key = this.lastKeyOf(searchValue);
return key === undefined ? -1 : key;

// var index =
// return this.toSeq().reverse().indexOf(searchValue);
},

reverse: function() {
Expand Down Expand Up @@ -4784,8 +4774,8 @@
// ### More collection methods

findLastIndex: function(predicate, context) {
var key = this.toKeyedSeq().findLastKey(predicate, context);
return key === undefined ? -1 : key;
var entry = this.findLastEntry(predicate, context);
return entry ? entry[0] : -1;
},

first: function() {
Expand Down Expand Up @@ -4826,6 +4816,10 @@
return reify(this, interleaved);
},

keySeq: function() {
return Range(0, this.size);
},

last: function() {
return this.get(-1);
},
Expand Down Expand Up @@ -4874,6 +4868,7 @@
});

SetIterable.prototype.has = IterablePrototype.includes;
SetIterable.prototype.contains = SetIterable.prototype.includes;


// Mixin subclasses
Expand Down Expand Up @@ -4910,7 +4905,7 @@
}

function quoteString(value) {
return typeof value === 'string' ? JSON.stringify(value) : value;
return typeof value === 'string' ? JSON.stringify(value) : String(value);
}

function defaultZipper() {
Expand Down

0 comments on commit 43cfabb

Please sign in to comment.