Add ramda

This commit is contained in:
Andros Fenollosa 2020-06-30 22:26:12 +02:00
parent bf1e55c0dc
commit f4f1ea6572
5 changed files with 41 additions and 14 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
test.html
node_modules/

16
dist/ffnm.min.js vendored
View File

@ -12,13 +12,15 @@ var EVENTS;
// FUNCTIONS
//===
function validateSyntax() {
// Check every event
var eventsKeys = Object.keys(EVENTS).filter(function (key) { return !isNaN(Number(EVENTS[key])); });
eventsKeys.forEach(function (event) {
var ddd = document.querySelector("[" + event + "]").length;
console.log(ddd);
});
return true;
// Get every items from EVENTS
var eventsKeys = R.filter(function (key) { return !isNaN(Number(EVENTS[key])); }, Object.keys(EVENTS));
// Check all event syntax
return eventsKeys.map(function (event) {
return R.map(function (element) {
console.log(element.getAttribute(event));
return /^${event}/.test(element.getAttribute(event));
}, document.querySelectorAll("[" + event + "]")).every(function (item) { return item; });
}).every(function (event) { return event; });
}
//===
// LINTER

11
package-lock.json generated Normal file
View File

@ -0,0 +1,11 @@
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"@types/ramda": {
"version": "github:types/npm-ramda#9529aa3c8ff70ff84afcbc0be83443c00f30ea90",
"from": "github:types/npm-ramda#dist",
"dev": true
}
}
}

View File

@ -1,3 +1,4 @@
//===
// VARIABLES
//===
@ -8,13 +9,16 @@ enum EVENTS {'i-click', 'i-scroll-up', 'i-scroll-down', 'i-hover'}
//===
function validateSyntax(): boolean {
// Check every event
let eventsKeys = Object.keys(EVENTS).filter(key => !isNaN(Number(EVENTS[key])));
eventsKeys.forEach((event) => {
let ddd = document.querySelector(`[${event}]`).length
console.log(ddd)
})
return true
// Get every items from EVENTS
let eventsKeys: string[] = R.filter(key => !isNaN(Number(EVENTS[key])), Object.keys(EVENTS));
// Check all event syntax
return eventsKeys.map((event) => {
return R.map((element) => {
console.log(element.getAttribute(event))
return /^${event}/.test(element.getAttribute(event))
}, document.querySelectorAll(`[${event}]`)).every(item => item)
}).every(event => event)
}

9
tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"lib": [
"es6",
"dom",
"dom.iterable"
]
}
}