|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
664 bytes
|
| Line | |
|---|
| 1 | import { keysIn } from './keysIn.mjs';
|
|---|
| 2 | import { mapToEntries } from '../_internal/mapToEntries.mjs';
|
|---|
| 3 | import { setToEntries } from '../_internal/setToEntries.mjs';
|
|---|
| 4 |
|
|---|
| 5 | function toPairsIn(object) {
|
|---|
| 6 | if (object == null) {
|
|---|
| 7 | return [];
|
|---|
| 8 | }
|
|---|
| 9 | if (object instanceof Set) {
|
|---|
| 10 | return setToEntries(object);
|
|---|
| 11 | }
|
|---|
| 12 | if (object instanceof Map) {
|
|---|
| 13 | return mapToEntries(object);
|
|---|
| 14 | }
|
|---|
| 15 | const keys = keysIn(object);
|
|---|
| 16 | const result = new Array(keys.length);
|
|---|
| 17 | for (let i = 0; i < keys.length; i++) {
|
|---|
| 18 | const key = keys[i];
|
|---|
| 19 | const value = object[key];
|
|---|
| 20 | result[i] = [key, value];
|
|---|
| 21 | }
|
|---|
| 22 | return result;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | export { toPairsIn };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.