import create from 'xoid'
import React from 'react'
const App = ($props, { effect, read }) => {
const $count = create(0)
const increment = () => $count.update(state => state + 1)
// conditionally callable context reader
const htmlTag = document.querySelector('html') | |
const checkDarkMode = () => htmlTag.hasAttribute('dark') | |
const watchDarkMode = (onChange) => { | |
let isDark, isDarkBefore | |
isDark = checkDarkMode() | |
onChange(isDark) | |
const observer = new MutationObserver(mutations => { | |
mutations.forEach(mutation => { |
This is my take on building a parser combinator library API in JavaScript. This library would have a very low surface area, and would be easy to learn for those who already know already know regex.
Parser combinators often create their own DSL (domain-specific language) to provide a less verbose way of declaring parsers. These DSLs have to support operators for things such as repetition, alternation, optionality, lookahead, and more. Some of them don't create DSLs and provide these as helper functions.
In the following link, there are JSON parser implementations done by several parser combinatiors/generators: https://chevrotain.io/performance/ Some of them are verbose, some of them are concise.
This parser combinator API I'm proposing will not provide a DSL, however it will result in very short parser declarations.
const Tree = (props) => ( | |
<ul> | |
{props.nodes.map((node, key) => ( | |
<li key={key}> | |
<div className={'name'}>{node.name}</div> | |
{node.children && <Tree nodes={node.children} />} | |
</li> | |
))} | |
</ul> | |
); |
Windows Registry Editor Version 5.00 | |
[HKEY_CLASSES_ROOT\Directory\shell\vscode] | |
@="Open Folder as &VS Code Project" | |
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command] | |
@="\"C:\\Users\\REPLACE_THIS_WITH_YOUR_USERNAME\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\"" | |
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode] | |
@="Open Folder as &VS Code Project" |
/** | |
* Code taken from @lrsjng/lolight - Lightweight tokenizer and syntax highlighter. | |
* https://larsjung.de/lolight/ | |
*/ | |
var KEYWORD_RE = /^(a(bstract|lias|nd|rguments|rray|s(m|sert)?|uto)|b(ase|egin|ool(ean)?|reak|yte)|c(ase|atch|har|hecked|lass|lone|ompl|onst|ontinue)|de(bugger|cimal|clare|f(ault|er)?|init|l(egate|ete)?)|do|double|e(cho|ls?if|lse(if)?|nd|nsure|num|vent|x(cept|ec|p(licit|ort)|te(nds|nsion|rn)))|f(allthrough|alse|inal(ly)?|ixed|loat|or(each)?|riend|rom|unc(tion)?)|global|goto|guard|i(f|mp(lements|licit|ort)|n(it|clude(_once)?|line|out|stanceof|t(erface|ernal)?)?|s)|l(ambda|et|ock|ong)|m(odule|utable)|NaN|n(amespace|ative|ext|ew|il|ot|ull)|o(bject|perator|r|ut|verride)|p(ackage|arams|rivate|rotected|rotocol|ublic)|r(aise|e(adonly|do|f|gister|peat|quire(_once)?|scue|strict|try|turn))|s(byte|ealed|elf|hort|igned|izeof|tatic|tring|truct|ubscript|uper|ynchronized|witch)|t(emplate|hen|his|hrows?|ransient|rue|ry|ype(alias|def|id|name|of))|u(n(checked|def(ined)?|ion|less|signed|til)|se|sing |
{ | |
"accent_color": "#00bcab", | |
"background_color": "#394145", | |
"font_face": "Segoe UI", | |
"tab_font_size": ["subtract", "$font_size", 1], | |
"show_tab_dropdown_button": false, | |
"panel_border_width": [0, 0, 0, 0], | |
"scrollbar_flavor": "square", | |
"sidebar_heading_font_size": ["subtract", "$font_size", 2], |
window.addEventListener("mousemove", function(e) { | |
debounce(200, fn.bind(this,e)) | |
}); | |
var waitFlag = false | |
function debounce(time,fn) { | |
if (!waitFlag) { | |
fn() | |
waitFlag = true |
var cnv = $('canvas')[0]; | |
var ctx = cnv.getContext('2d'); | |
var ratio = window.devicePixelRatio | |
if (ratio) { | |
ratio *= 1.5; | |
var w = $(cnv).attr('width'); | |
var h = $(cnv).attr('height'); |
html { | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale; | |
font: 400 16px/1.5 system-ui,-apple-system,BlinkMacSystemFont,"Helvetica Neue",Helvetica,Arial,sans-serif; | |
text-rendering: optimizeLegibility; | |
} |