This repository has been archived by the owner on Dec 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return values from an object
- Loading branch information
Showing
3 changed files
with
25 additions
and
0 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,12 @@ | ||
import values, { _values } from '../values'; | ||
|
||
test('Core.values', () => { | ||
expect(values({ a: 1, b: 2, c: 3 })).toEqual([1, 2, 3]); | ||
|
||
global.Object.values = undefined; | ||
expect(values({ a: 1, b: 2, c: 3 })).toEqual([1, 2, 3]); | ||
}); | ||
|
||
test('Internal._values', () => { | ||
expect(_values({ a: 1, b: 2, c: 3 })).toEqual([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
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,11 @@ | ||
/* eslint-disable no-underscore-dangle */ | ||
|
||
import append from './append'; | ||
import keys from './keys'; | ||
import prop from './prop'; | ||
import reduce from './reduce'; | ||
|
||
export const _values = obj => | ||
reduce((acc, key) => append(prop(key, obj), acc), [], keys(obj)); | ||
|
||
export default Object.valuse || _values; |