esm/index.js <= the real stuff
cjs/index.js <= the CommonJSified stuff
index.js <= the unminified browser bundle
min.js <= the minified browser bundle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function removeColumn($0) { | |
| let tr = $0.closest('tr'); | |
| const index = [].indexOf.call(tr.querySelectorAll($0.nodeName), $0); | |
| $0.remove(); | |
| tr = tr.closest('thead').nextElementSibling.querySelector('tr'); | |
| do { | |
| let td = tr.querySelectorAll('td'); | |
| if (td.length) td[index - 1].remove(); | |
| else tr.querySelectorAll('th')[index].remove(); | |
| } while (tr = tr.nextElementSibling); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.documentElement.appendChild( | |
| document.createElement('style') | |
| ).textContent = ` | |
| .executable { | |
| transition: all .3s; | |
| } | |
| .executable:hover { | |
| cursor: pointer; | |
| background: #fff !important; | |
| }`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // used to retrieve template content | |
| const templates = new WeakMap; | |
| // used to retrieve node updates | |
| const updates = new WeakMap; | |
| // hyperHTML, the nitty gritty | |
| function hyperHTML(chunks, ...interpolations) { | |
| // if the static chunks are unknown |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const JSONChannel = (Private => class JSONChannel { | |
| // (c) Andrea Giammarchi - @WebReflection (ISC) | |
| constructor(secret=Array.from( | |
| crypto.getRandomValues(new Uint8Array(8)) | |
| ).map(i => i.toString(36)).join('')) { | |
| const listener = e => this.emit('message', null, e.detail); | |
| document.addEventListener(`${secret}:gjs`, listener); | |
| Private.set(this, { | |
| secret, listener, | |
| fn: Object.create(null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| i18n.set('en')`Date: ${'month'}/${'day'}/${'year'}` | |
| .for('it')`Data: ${'year'}/${'month'}/${'day'}`; | |
| // default | |
| const d = new Date; | |
| i18n.locale = 'en'; | |
| i18n`Date: ${d.getMonth() + 1}/${d.getDate()}/${d.getFullYear()}` | |
| // "Date: 10/22/2017" | |
| i18n.locale = 'it'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // default | |
| i18n`Hello ${'World'}` | |
| // "Hello World" | |
| // we switch to German | |
| i18n.locale = 'de'; | |
| // but we still write in English | |
| i18n`Hello ${'World'}` | |
| // "Hallo World" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| i18n.set('en')`Hello ${'name'}` | |
| .for('de')`Hallo ${'name'}` | |
| .for('it')`Ciao ${'name'}` | |
| .for('sp')`Hola ${'name'}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| i18n.set = locale => (tCurrent, ...rCurrent) => { | |
| const key = tCurrent.join('\x01'); | |
| let db = i18n.db[locale] || (i18n.db[locale] = {}); | |
| db[key] = { | |
| t: tCurrent.slice(), | |
| v: rCurrent.map((value, i) => i) | |
| }; | |
| const config = { | |
| for: other => (tOther, ...rOther) => { | |
| db = i18n.db[other] || (i18n.db[other] = {}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function i18n(template) { | |
| for (var | |
| info = i18n.db[i18n.locale][template.join('\x01')], | |
| out = [info.t[0]], | |
| i = 1, length = info.t.length; i < length; i++ | |
| ) out[i] = arguments[1 + info.v[i - 1]] + info.t[i]; | |
| return out.join(''); | |
| } | |
| i18n.locale = 'en'; | |
| i18n.db = {}; |