-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from NodeGuy/List
Add basic List support.
- Loading branch information
Showing
7 changed files
with
37 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lib | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
machine: | ||
node: | ||
version: 5.6.0 | ||
version: 6.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import Immutable from 'immutable' | ||
import List from './list' | ||
import Map from './map' | ||
|
||
module.exports = { | ||
...Immutable, | ||
List, | ||
Map | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { List } from 'immutable' | ||
|
||
export default initialData => { | ||
const immutableList = List(initialData) | ||
|
||
return new Proxy(immutableList, { | ||
get: (proxy, name) => { | ||
const immutableName = name === 'length' | ||
? 'size' | ||
: name | ||
|
||
return immutableList.get(immutableName) || immutableList[immutableName] | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import List from '../src/list' | ||
import { expect } from 'chai' | ||
|
||
describe('List Proxy', () => { | ||
it('should access value without calling .get', () => { | ||
const data = List([1, 2, 3]) | ||
expect(data[1]).to.equal(2) | ||
}) | ||
|
||
it('should provide the "length" property', () => { | ||
const data = List([1, 2, 3]) | ||
expect(data.length).to.equal(3) | ||
}) | ||
}) |