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)) {
|
} else if (isObject(source)) {
|
||||||
if (source[Symbol.iterator as any]) {
|
if (source[Symbol.iterator as any]) {
|
||||||
ret = []
|
ret = Array.from(
|
||||||
const iterator: Iterator<any> = source[Symbol.iterator as any]()
|
source as Iterable<any>,
|
||||||
let result = iterator.next()
|
renderItem
|
||||||
while (!result.done) {
|
)
|
||||||
ret.push(renderItem(result.value, ret.length))
|
|
||||||
result = iterator.next()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const keys = Object.keys(source)
|
const keys = Object.keys(source)
|
||||||
ret = new Array(keys.length)
|
ret = new Array(keys.length)
|
||||||
|
Loading…
Reference in New Issue
Block a user