@mdui/jq
Version:
拥有和 jQuery 相似 API 的轻量级 JavaScript 工具库
16 lines (15 loc) • 485 B
JavaScript
import { getWindow } from 'ssr-window';
import { each } from './each.js';
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-function-type
export function map(elements, callback) {
const window = getWindow();
let value;
const ret = [];
each(elements, (i, element) => {
value = callback.call(window, element, i);
if (value != null) {
ret.push(value);
}
});
return [].concat(...ret);
}