How to use the is function from immutable

Find comprehensive JavaScript immutable.is code examples handpicked from public code repositorys.

722
723
724
725
726
727
728
729
730
731
*
*     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.
*
fork icon2
star icon1
watch icon0

+ 4 other calls in file

16
17
18
19
20
21
22
23
24
25
  /**
   * Immutable data structures should only contain other immutable
   * data structures to be considered immutable and work against `equal()`.
   * http://facebook.github.io/immutable-js/docs/#/is
   */
  return is(a, b);
},
inspect: function(collection, depth, output, inspect) {
  const prefixOutput = this.prefix(output.clone(), collection);
  const suffixOutput = this.suffix(output.clone(), collection);
fork icon1
star icon2
watch icon0

10
11
12
13
14
15
16
17
18
19
  /**
   * Immutable data structures should only contain other immutable
   * data structures to be considered immutable and work against `equal()`.
   * http://facebook.github.io/immutable-js/docs/#/is
   */
  return is(a, b)
},
inspect: function (collection, depth, output, inspect) {
  const prefixOutput = this.prefix(output.clone(), collection)
  const suffixOutput = this.suffix(output.clone(), collection)
fork icon1
star icon0
watch icon1

7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
},{}],6:[function(require,module,exports){
///<reference path="./references.d.ts" />
"use strict";
var immutable_1 = require("immutable");
exports.List = immutable_1.List;
exports.is = immutable_1.is;
var Repliq_1 = require("./Repliq");
exports.Repliq = Repliq_1.Repliq;
var Time_1 = require("./protocols/Time");
exports.Time = Time_1.Time;
fork icon0
star icon1
watch icon0

+ 12 other calls in file

1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
 *
 * @author Andrew McLagan <andrew@ethicaljobs.com.au>
 */


function initialState(reducer, expectedState) {
  return Immutable.is(reducer(undefined), expectedState);
}


/**
 * Asserts a modules "cleared" state
fork icon1
star icon0
watch icon2

+ 14 other calls in file

27
28
29
30
31
32
33
34
35
36
37
38


const makeSet = (...xs) => im.Map(xs)
const makeList = (...xs) => im.List(xs)
const makeForm = (name, ...args) => makeList(sym(name), ...args)


const is = im.is
const isSym = x => x instanceof Sym
const isList = x => im.List.isList(x)
const isSet = x => im.Map.isMap(x)
const isFn = x => typeof x === 'function'
fork icon0
star icon3
watch icon1

48
49
50
51
52
53
54
55
56
57
58
59
60


const isType = (x, t) =>
  getType(x) === t


const is = (x, y) =>
  getType(x) === getType(y) && im.is(x, y)


const isForm = (x, ...names) =>
  isList(x) && names.some(name => is(x.first(), sym(name)))

fork icon0
star icon0
watch icon0

293
294
295
296
297
298
299
300
301
302
call: x => chalk.cyan('(') + printChildren(x, 0) + chalk.cyan(')'),
list: x => chalk.cyan('[') + printChildren(x, 0) + chalk.cyan(']'),
set: x => (
  chalk.cyan('{') +
  printChildren(x.entrySeq().map(([k, v]) =>
    im.is(k, v) ? v : bind(k, v)), 0) +
  chalk.cyan('}')),
expand: x => chalk.cyan('$') + printChildren(x, 1),
quote: x => chalk.cyan('\\') + printChildren(x, 1),
boolean: chalk.yellow,
fork icon0
star icon0
watch icon0