Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
feat(values): Add module values
Browse files Browse the repository at this point in the history
Return values from an object
  • Loading branch information
adambrgmn committed Jan 16, 2018
1 parent c1287e5 commit 5d6fab1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/__tests__/values.js
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]);
});
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import reverse from './reverse';
import slice from './slice';
import T from './T';
import update from './update';
import values from './values';

export {
adjust,
Expand Down Expand Up @@ -80,4 +81,5 @@ export {
slice,
T,
update,
values,
};
11 changes: 11 additions & 0 deletions src/values.js
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;

0 comments on commit 5d6fab1

Please sign in to comment.