vanillajs-browser-helpers
Version:
Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS in the browser
19 lines (18 loc) • 601 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const isString_1 = __importDefault(require("vanillajs-helpers/isString"));
const byId = (id) => document.getElementById(id);
function findById(ids) {
if (isString_1.default(ids)) {
return byId(ids);
}
return ids.reduce((nodes, id) => {
const node = byId(id);
node && nodes.push(node);
return nodes;
}, []);
}
exports.default = findById;