refactor(runtime-core): use Array.from
instead of loop over iterable
(#250)
This commit is contained in:
parent
96681942c1
commit
cdc143d348
@ -16,13 +16,10 @@ export function renderList(
|
||||
}
|
||||
} else if (isObject(source)) {
|
||||
if (source[Symbol.iterator as any]) {
|
||||
ret = []
|
||||
const iterator: Iterator<any> = source[Symbol.iterator as any]()
|
||||
let result = iterator.next()
|
||||
while (!result.done) {
|
||||
ret.push(renderItem(result.value, ret.length))
|
||||
result = iterator.next()
|
||||
}
|
||||
ret = Array.from(
|
||||
source as Iterable<any>,
|
||||
renderItem
|
||||
)
|
||||
} else {
|
||||
const keys = Object.keys(source)
|
||||
ret = new Array(keys.length)
|
||||
|
Loading…
Reference in New Issue
Block a user