-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQs.f.js
60 lines (54 loc) · 1.25 KB
/
Qs.f.js
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
50
51
52
53
54
55
56
57
58
59
60
// Foreach
/**
* A function with one parameter.
*
* @callback lambdaOne
* @param {Object} param the prameter
*/
/**
* Call a function for each element inside an array.
* Stands for ForeachcallFunction.
*
* @param {Object[]} l the array of objects
* @param {lambdaOne} f the function
*/
function ff (l, f) {
var count = l.length
for (var i = 0; i < count; i += 1) {
f(l[i])
}
}
/**
* Call a function for each element that match the specified selectors.
* Stands for QueryAllForeachcallFunction.
*
* @param {string} text the selectors
* @param {lambdaOne} f the function
*/
function qaff (text, f) {
ff(document.querySelectorAll(text), f)
}
/**
* Call a function for each element that match the specified selectors inside a
* given parrent element.
* Stands for QueryAllSubForeachcallFunction.
*
* @param {Element} sub the parrent element
* @param {string} text the selectors
* @param {lambdaOne} f the function
*/
function qasff (sub, text, f) {
ff(sub.querySelectorAll(text), f)
}
/**
* Call a function for each integer number from 0 to given limit.
* Stands for ForeachIntegercallFunction.
*
* @param {Number} n the limit
* @param {lambdaOne} f the function
*/
function fif (n, f) {
for (var i = 0; i < n; i += 1) {
f(i)
}
}