File tree Expand file tree Collapse file tree 7 files changed +37
-21
lines changed Expand file tree Collapse file tree 7 files changed +37
-21
lines changed Original file line number Diff line number Diff line change
1
+ lib
2
+ node_modules
Original file line number Diff line number Diff line change 1
1
machine :
2
2
node :
3
- version : 5.6 .0
3
+ version : 6.1 .0
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2
2
"name" : " immutable-proxy" ,
3
3
"version" : " 0.0.1" ,
4
4
"description" : " access immutable values more easily" ,
5
- "main" : " index.js" ,
5
+ "main" : " lib/ index.js" ,
6
6
"peerDependencies" : {
7
7
"immutable" : " ^3.7.6"
8
8
},
19
19
},
20
20
"scripts" : {
21
21
"test" : " mocha tests --compilers js:babel-register --recursive --harmony_shipping " ,
22
- "build" : " babel src/index.js --out-file index.js && npm run build-umd && npm run build-min" ,
22
+ "build" : " babel src -d lib && npm run build-umd && npm run build-min" ,
23
23
"build-umd" : " NODE_ENV=production webpack src/index.js umd/index.js" ,
24
24
"build-min" : " NODE_ENV=production webpack -p src/index.js umd/index.min.js"
25
25
},
Original file line number Diff line number Diff line change 1
1
import Immutable from 'immutable'
2
+ import List from './list'
2
3
import Map from './map'
3
4
4
5
module . exports = {
5
6
...Immutable ,
7
+ List,
6
8
Map
7
- }
9
+ }
Original file line number Diff line number Diff line change
1
+ import { List } from 'immutable'
2
+
3
+ export default initialData => {
4
+ const immutableList = List ( initialData )
5
+
6
+ return new Proxy ( immutableList , {
7
+ get : ( proxy , name ) => {
8
+ const immutableName = name === 'length'
9
+ ? 'size'
10
+ : name
11
+
12
+ return immutableList . get ( immutableName ) || immutableList [ immutableName ]
13
+ }
14
+ } )
15
+ }
Original file line number Diff line number Diff line change
1
+ import List from '../src/list'
2
+ import { expect } from 'chai'
3
+
4
+ describe ( 'List Proxy' , ( ) => {
5
+ it ( 'should access value without calling .get' , ( ) => {
6
+ const data = List ( [ 1 , 2 , 3 ] )
7
+ expect ( data [ 1 ] ) . to . equal ( 2 )
8
+ } )
9
+
10
+ it ( 'should provide the "length" property' , ( ) => {
11
+ const data = List ( [ 1 , 2 , 3 ] )
12
+ expect ( data . length ) . to . equal ( 3 )
13
+ } )
14
+ } )
You can’t perform that action at this time.
0 commit comments