source: node_modules/es-toolkit/dist/compat/object/toPairs.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 662 bytes
Line 
1import { keys } from './keys.mjs';
2import { mapToEntries } from '../_internal/mapToEntries.mjs';
3import { setToEntries } from '../_internal/setToEntries.mjs';
4
5function toPairs(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$1 = keys(object);
16 const result = new Array(keys$1.length);
17 for (let i = 0; i < keys$1.length; i++) {
18 const key = keys$1[i];
19 const value = object[key];
20 result[i] = [key, value];
21 }
22 return result;
23}
24
25export { toPairs };
Note: See TracBrowser for help on using the repository browser.