-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Object.entries with utility function 🥴
A previous change introduced the use of Object.entries, which is not available in some browsers supported by Mobiledoc (most notably IE11). This commit replaces Object.entries with a utility function `entries` with the same functionality.
- Loading branch information
Showing
6 changed files
with
45 additions
and
13 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,11 @@ | ||
export function entries(obj) { | ||
const ownProps = Object.keys(obj); | ||
let i = ownProps.length; | ||
const resArray = new Array(i); | ||
|
||
while (i--) { | ||
resArray[i] = [ownProps[i], obj[ownProps[i]]]; | ||
} | ||
|
||
return resArray; | ||
} |
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,13 @@ | ||
import Helpers from '../../test-helpers'; | ||
import { entries } from 'mobiledoc-kit/utils/object-utils'; | ||
|
||
const { module, test } = Helpers; | ||
|
||
module('Unit: Utils: Object Utils'); | ||
|
||
test('#entries works', assert => { | ||
assert.deepEqual(entries({ hello: 'world', goodbye: 'moon' }), [ | ||
['hello', 'world'], | ||
['goodbye', 'moon'] | ||
]); | ||
}); |