Spike events system

This commit is contained in:
Jose Farias
2024-10-11 20:14:09 -05:00
parent 9e2ca7ad4b
commit ec7fc75054
46 changed files with 436 additions and 146 deletions
+25
View File
@@ -0,0 +1,25 @@
// On-demand JavaScript objects from "current" HTML <meta> elements. Example:
//
// <meta name="current-identity-id" content="123">
// <meta name="current-identity-time-zone-name" content="Central Time (US & Canada)">
//
// >> current.identity
// => { id: "123", timeZoneName: "Central Time (US & Canada)" }
//
// >> current.foo
// => {}
export const current = new Proxy({}, {
get(_target, propertyName) {
const result = {}
const prefix = `current-${propertyName}-`
for (const { name, content } of document.head.querySelectorAll(`meta[name^=${prefix}]`)) {
const key = camelize(name.slice(prefix.length))
result[key] = content
}
return result
}
})
function camelize(string) {
return string.replace(/(?:[_-])([a-z0-9])/g, (_, char) => char.toUpperCase())
}
+2
View File
@@ -0,0 +1,2 @@
export * from "helpers/current_helpers"
export * from "helpers/timing_helpers"