* 数组映射 * @memberOf module:zrender/core/util * @param {Array} obj * @param {Function} cb * @param {*} [context] * @return {Array}
(obj, cb, context)
| 559 | * @return {Array} |
| 560 | */ |
| 561 | function map(obj, cb, context) { |
| 562 | if (!(obj && cb)) { |
| 563 | return; |
| 564 | } |
| 565 | if (obj.map && obj.map === nativeMap) { |
| 566 | return obj.map(cb, context); |
| 567 | } |
| 568 | else { |
| 569 | var result = []; |
| 570 | for (var i = 0, len = obj.length; i < len; i++) { |
| 571 | result.push(cb.call(context, obj[i], i, obj)); |
| 572 | } |
| 573 | return result; |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | /** |
| 578 | * @memberOf module:zrender/core/util |
no test coverage detected