-
Notifications
You must be signed in to change notification settings - Fork 8
/
ajquery.cjs
49 lines (42 loc) · 1.27 KB
/
ajquery.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* AJQuery - The fastest, most lightweight, least dependency jQuery alternative,
* now typed, Ai-enhanced, and better than ever!
* @typedef AJQuery
* @prop {AJQuerySelector} $
* @prop {AJQuerySelectorAll} $$
*/
/**
* Select first matching element, just like console $
* @callback AJQuerySelector
* @param {String} cssSelector
* @param {ParentNode} [$parent=document]
*/
/**
* Select all matching child elements as a JS Array, just like console $$
* @callback AJQuerySelectorAll
* @param {String} cssSelector
* @param {ParentNode} [$parent=document]
*/
/** @type {AJQuery} */
//@ts-ignore
var AJQuery = ("object" === typeof module && exports) || {};
(function (window, AJQuery) {
"use strict";
/** @type {AJQuerySelector} */
AJQuery.$ = function (cssSelector, $parent = document) {
let $child = $parent.querySelector(cssSelector);
return $child;
};
/** @type {AJQuerySelectorAll} */
AJQuery.$$ = function (cssSelector, $parent = document) {
let nodeList = $parent.querySelectorAll(cssSelector);
let $children = Array.from(nodeList);
return $children;
};
Object.assign(window, AJQuery);
//@ts-ignore
window.AJQuery = AJQuery;
})(globalThis.window || {}, AJQuery);
if ("object" === typeof module) {
module.exports = AJQuery;
}