@@ -51,37 +51,41 @@ map1.get('b') + " vs. " + map2.get('b') // 2 vs. 50
51
51
52
52
### Browser
53
53
54
- To use Immutable.js from a browser, download [ dist/immutable.min.js] ( https://github.com/facebook/immutable-js/blob/master/dist/immutable.min.js )
55
- or use a CDN such as [ CDNJS] ( https://cdnjs.com/libraries/immutable )
56
- or [ jsDelivr] ( http://www.jsdelivr.com/#!immutable.js ) .
54
+ Immutable.js has no depenencnies, which makes it predictable to include in a Browser.
57
55
58
- Then, add it as a script tag to your page:
56
+ It's highly recommended to use a module bundler like [ webpack] ( https://webpack.github.io/ ) ,
57
+ [ rollup] ( https://rollupjs.org/ ) , or
58
+ [ browserify] ( http://browserify.org/ ) . The ` immutable ` npm module works
59
+ without any additional consideration. All examples throughout the documentation
60
+ will assume use of this kind of tool.
61
+
62
+ Alternatively, Immutable.js may be directly included as a script tag. Download
63
+ or link to a CDN such as [ CDNJS] ( https://cdnjs.com/libraries/immutable )
64
+ or [ jsDelivr] ( https://www.jsdelivr.com/package/npm/immutable ) .
65
+
66
+ Use a script tag to directly add ` Immutable ` to the global scope:
59
67
60
68
``` html
61
69
<script src =" immutable.min.js" ></script >
62
70
<script >
63
- var map1 = Immutable .Map ({a: 1 , b: 2 , c: 3 });
64
- var map2 = map1 .set (' b' , 50 );
65
- map1 .get (' b' ); // 2
66
- map2 .get (' b' ); // 50
71
+ var map1 = Immutable .Map ({a: 1 , b: 2 , c: 3 });
72
+ var map2 = map1 .set (' b' , 50 );
73
+ map1 .get (' b' ); // 2
74
+ map2 .get (' b' ); // 50
67
75
</script >
68
76
```
69
77
70
- Or use an AMD loader (such as [ RequireJS] ( http://requirejs.org/ ) ):
78
+ Or use an AMD-style loader (such as [ RequireJS] ( http://requirejs.org/ ) ):
71
79
72
80
``` js
73
81
require ([' ./immutable.min.js' ], function (Immutable ) {
74
- var map1 = Immutable .Map ({a: 1 , b: 2 , c: 3 });
75
- var map2 = map1 .set (' b' , 50 );
76
- map1 .get (' b' ); // 2
77
- map2 .get (' b' ); // 50
82
+ var map1 = Immutable .Map ({a: 1 , b: 2 , c: 3 });
83
+ var map2 = map1 .set (' b' , 50 );
84
+ map1 .get (' b' ); // 2
85
+ map2 .get (' b' ); // 50
78
86
});
79
87
```
80
88
81
- If you're using [ webpack] ( https://webpack.github.io/ ) or
82
- [ browserify] ( http://browserify.org/ ) , the ` immutable ` npm module also works
83
- from the browser.
84
-
85
89
### Flow & TypeScript
86
90
87
91
Use these Immutable collections and sequences as you would use native
0 commit comments