How to use the Record function from immutable

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

158
159
160
161
162
163
164
165
166

TreeNode.asMutable = asMutable;
function asMutable(tree) {
    const children = tree.getChildren().map(asMutable).asMutable();
    tree = tree.set('children', children);
    return Immutable.Record.prototype.asMutable.call(tree);
}

module.exports = TreeNode;
fork icon18
star icon75
watch icon7

+ 41 other calls in file

6
7
8
9
10
11
12
13
14
15
16
17
var denormalize = require('../src').denormalize;


var immutable = require('immutable');
var fromJS = immutable.fromJS;
var Map = immutable.Map;
var Record = immutable.Record;
var List = immutable.List;


var normalizr = require('normalizr');
var normalize = normalizr.normalize;
fork icon3
star icon9
watch icon2

+ 8 other calls in file

18
19
20
21
22
23
24
25
26


  _prototype.setError = function(error) {
    return _prototype._validationErrors = [error]
  }


  return I.Record(args);
}
fork icon0
star icon4
watch icon0

12
13
14
15
16
17
18
19
20
21
22
23
24


// Language primitives
const identity = x => x


const compFlag = im.Record({}, 'complement')({})
const Sym = im.Record({ sym: null }, 'Sym')
const makeSym = sym => Sym({ sym })


const syms = { env: makeSym('env') }
const sym = name => {
fork icon0
star icon3
watch icon1

738
739
740
741
742
743
744
745
746
747
748
749
var Immutable = require('immutable');
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) {
fork icon0
star icon1
watch icon0

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


    this.value = route;
  }
}


var StackDiffRecord = immutable.Record({
  key: null,
  route: null,
  index: null,
});
fork icon0
star icon0
watch icon2

177
178
179
180
181
182
183
184
185
  // OrderedMap is handled the same as Map, so ordering is lost
});

// Record
test('Record', () => {
  const R = immutable.Record({foo: undefined});
  const r = R({foo: 1});
  expect(stableStringify(r)).toBe('{"foo":1}');
});
fork icon0
star icon0
watch icon1

14
15
16
17
18
19
20
21
22
23
24
25
const throwError = msg => {
  throw new Error(msg)
}


// Language primitives
const Sym = im.Record({ name: null }, 'Sym')
const makeSym = name => Sym({ name })


const syms = { env: makeSym('env') }
const sym = name => {
fork icon0
star icon0
watch icon0

7
8
9
10
11
12
13
14
15
16
17
18
19


const ebnf = require('ebnf')


const lsnParser = new ebnf.Grammars.W3C.Parser(fs.readFileSync(path.resolve(__dirname, 'lsn.ebnf.w3c')).toString())


const Symbol2 = im.Record({ sym: null }, 'Symbol2')
const Bind = im.Record({ k: null, v: null }, 'Bind')
const symbol = sym => Symbol2({ sym })
const sym = Object.fromEntries([
  '_',
fork icon0
star icon0
watch icon0

+ 2 other calls in file

21
22
23
24
25
26
27
28
29
30
31
32
33


var Immutable = require("immutable");


var List = Immutable.List,
    Repeat = Immutable.Repeat,
    Record = Immutable.Record;


var returnTrue = function returnTrue() {
  return true;
};
fork icon0
star icon0
watch icon0