The createFragment
function returns an HTML fragment from a string.
[
{ name: 'Hedral', coat: 'Tuxedo', legs: 4 },
{ name: 'Pillar', coat: 'Ticked Tabby', legs: 3 },
].reduce(
(table, { name, coat, legs }) => {
/** Returns a new object with all entries that pass the test implemented by the provided function. */ | |
function filteredObject<T>(object: { [s: string]: T } | ArrayLike<T>, predicate: (value: T, name: string, array: [string, T][]) => unknown): { [s: string]: T } { | |
const newObject = Object.create(Object(object).prototype) | |
const entries = Object.entries(object) | |
for (const [name, value] of entries) { | |
if (predicate(value, name, entries)) { | |
Reflect.set(newObject, name, Reflect.get(object, name)) | |
} | |
} | |
return newObject |
HTMLSelectorSlotElement = ((internal, filter) => class HTMLSelectorSlotElement extends HTMLElement { | |
constructor() { | |
internal.set(super(), [ | |
this.attachShadow({ mode: 'open' }), | |
document.createElement('slot'), | |
document.createElement('slot'), | |
new MutationObserver(HTMLSelectorSlotElement.prototype.connectedCallback.bind(this)), | |
[] | |
]) | |
} |
Should there be a need to fetch web platform data in NodeJS, here are some dependency-less functions that will return feature data from W3C, CanIUse, and MDN Browser Compatibility Data.
NodeJS includes an http
and https
library which can perform network requests.
const https = require('https')
[ | |
{ | |
"type": "Comment", | |
"value": "\n augmented-ui\n BSD 2-Clause License\n Copyright (c) James0x57, PropJockey, 2019\n", | |
"delimiterStart": "/*", | |
"delimiterEnd": "*/" | |
}, | |
{ | |
"type": "Space", | |
"value": "\n" |
This work was moved to https://github.com/csstools/tokenizer
!function () { | |
let WindowEvent = Event | |
try { | |
new WindowEvent('') | |
} catch (error) { | |
' Animation AudioProcessing BeforeUnload Clipboard Close Composition Custom Error Focus Gamepad HashChange IDBVersionChange Input Keyboard Message Mouse Mutation OfflineAudioCompletion PageTransition PaymentRequestUpdate Pointer PopState Progress Storage Track Transition UI WebGLContext Wheel' | |
.split(' ').forEach(function (eventName) { | |
eventName += 'Event' | |
let NativeEvent = window[eventName] || WindowEvent | |
let nativeEventName = NativeEvent === WindowEvent || eventName === 'InputEvent' ? 'Event' : eventName |
!function () { | |
let KeyboardEventPrototype = KeyboardEvent.prototype | |
let KeyboardEventPrototypeKeyDescriptor = Object.getOwnPropertyDescriptor(KeyboardEventPrototype, 'key') | |
let KeyboardEventPrototypeKeyGetter = KeyboardEventPrototypeKeyDescriptor.get | |
KeyboardEventPrototypeKeyDescriptor.get = function () { | |
return { | |
27: 'Escape', | |
29: 'NonConvert', | |
32: ' ', | |
37: 'ArrowLeft', |
Object.prototype.__defineGetter__('_t', function () { | |
return this | |
}), _t.globalThis = _t, delete Object.prototype._t |
closest = (function (Object, error) { | |
return function (targetElement, selectors, untilElement) { | |
let document = Object(Object(targetElement).ownerDocument) | |
let rootElement = Object(document.documentElement) | |
let Element = Object(document.defaultView).Element | |
untilElement = untilElement || rootElement | |
if (typeof Element === 'function' && targetElement instanceof Element && untilElement instanceof Element) { | |
while (untilElement.contains(targetElement)) { | |
if (targetElement.matches(selectors)) { | |
return targetElement |