File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 11import Immutable from 'immutable'
2+ import List from './list'
23import Map from './map'
34
45module . exports = {
56 ...Immutable ,
7+ List,
68 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