source:
node_modules/es-toolkit/dist/compat/array/size.mjs
| Last change on this file was a762898, checked in by , 5 months ago | |
|---|---|
|
|
| File size: 276 bytes | |
| Line | |
|---|---|
| 1 | import { isNil } from '../../predicate/isNil.mjs'; |
| 2 | |
| 3 | function size(target) { |
| 4 | if (isNil(target)) { |
| 5 | return 0; |
| 6 | } |
| 7 | if (target instanceof Map || target instanceof Set) { |
| 8 | return target.size; |
| 9 | } |
| 10 | return Object.keys(target).length; |
| 11 | } |
| 12 | |
| 13 | export { size }; |
Note:
See TracBrowser
for help on using the repository browser.
