UNPKG

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) 642 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var isString_1 = __importDefault(require("vanillajs-helpers/isString")); var byId = function (id) { return document.getElementById(id); }; function findById(ids) { if ((0, isString_1.default)(ids)) { return byId(ids); } return ids.reduce(function (nodes, id) { var node = byId(id); node && nodes.push(node); return nodes; }, []); } exports.default = findById;