How to use the Record function from immutable
Find comprehensive JavaScript immutable.Record code examples handpicked from public code repositorys.
GitHub: GitbookIO/repofs
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;
18
75
7
+ 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;
3
9
2
+ 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); }
0
4
0
GitHub: jclaggett/anascript
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 => {
0
3
1
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) {
0
1
0
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, });
0
0
2
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}'); });
0
0
1
GitHub: jclaggett/lsn
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 => {
0
0
0
GitHub: jclaggett/lsn
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([ '_',
0
0
0
+ 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; };
0
0
0
immutable.Map is the most popular function in immutable (1575 examples)