Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
110 additions
and
20 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
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import keys from '../keys' | ||
import { Map, List } from 'immutable' | ||
|
||
describe.only('Keys', function() { | ||
|
||
it ('works for objects', function() { | ||
keys({ a: 1, b: 2, c: 3 }).should.eql(['a', 'b', 'c']) | ||
}) | ||
|
||
it ('works for arrays', function() { | ||
keys([ 'a', 'b', 'c' ]).should.eql([ '0', '1', '2' ]) | ||
}) | ||
|
||
it.only ('works for maps', function() { | ||
let sample = Map({ a: 1, b: 2, c: 3 }) | ||
keys(sample).should.eql([ 'a', 'b', 'c']) | ||
}) | ||
|
||
it ('works for lists', function() { | ||
keys(List([1, 2, 3])).should.eql([0, 1, 2]) | ||
}) | ||
|
||
}) |
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,23 @@ | ||
import values from '../values' | ||
import { Map, Set } from 'immutable' | ||
|
||
describe('Values', function() { | ||
|
||
it ('works for objects', function() { | ||
values({ a: 1, b: 2, c: 3 }).should.eql([1,2,3]) | ||
}) | ||
|
||
it ('works for arrays', function() { | ||
values([ 1, 2, 3 ]).should.eql([1,2,3]) | ||
}) | ||
|
||
it ('works for maps', function() { | ||
let sample = Map({ a: 1, b: 2, c: 3 }) | ||
values(sample).should.eql([ 1, 2, 3]) | ||
}) | ||
|
||
it ('works for sets', function() { | ||
values(Set([1,2,3])).should.eql([1,2,3]) | ||
}) | ||
|
||
}) |
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,6 @@ | ||
let isImmutable = require('./isImmutable') | ||
|
||
module.exports = function(obj) { | ||
return isImmutable(obj) ? obj.map((value, key) => key).toArray() | ||
: Object.keys(obj || {}) | ||
} |
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,9 @@ | ||
let get = require('./get') | ||
let isImmutable = require('./isImmutable') | ||
let keys = require('./keys') | ||
|
||
module.exports = function(obj) { | ||
// An anonymous function is used here instead of calling | ||
// `get` directly because there is no fallback value. | ||
return keys(obj).map(key => get(obj, [ key ])) | ||
} |