Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deleight

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deleight - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

47

dist/cjs/actribute.js

@@ -13,4 +13,8 @@ 'use strict';

* @example
* import { Actribute } from 'deleight/actribute';
* // initialize:
* const fallbackProps = {prop1: 'Fallback', prop4: 'Last resort'};
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort',
* sig: '$2b$20$o7DWuroOjbA/4LDWIstjueW9Hi6unv4fI0xAit7UQfLw/PI8iPl1y'
* };
* const act = new Actribute(fallbackProps);

@@ -59,4 +63,6 @@ *

*
* When it is used to process markup, attributes with names starting
* with attrPrefix are assumed to be component specifiers.
* It is similar to a Custom Element registry. When used to process
* markup, attributes with names starting with `attrPrefix` are treated
* as component specifiers.
*
* A component specifier is of the form [attrPrefix][componentName]="[propertyName] [propertyName] ..."

@@ -74,2 +80,9 @@ *

*
* @example
* import { Actribute } from 'deleight/actribute';
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort'
* };
* const act = new Actribute(fallbackProps);
*
* @param {any} props The value to assign to the props member.

@@ -90,2 +103,11 @@ * @param {string} attrPrefix The value to assign to attrPrefix. Defaults to 'c-'

*
* @example
* import { Actribute } from 'deleight/actribute';
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort'
* };
* const act = new Actribute(fallbackProps);
* act.register('comp1', (node, prop1) => node.textContent = prop1);
* act.register('comp2', (node, prop2) => node.style.left = prop2);
*
* @param {string} name The component name

@@ -111,2 +133,12 @@ * @param {Function} component The component function

*
* @example
* import { Actribute } from 'deleight/actribute';
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort'
* };
* const act = new Actribute(fallbackProps);
* act.register('comp1', (node, prop1) => node.textContent = prop1);
* act.register('comp2', (node, prop2) => node.style.left = prop2);
* act.process(document.body, {prop2: 1, prop3: 2});
*
* @param {HTMLElement} element

@@ -166,2 +198,11 @@ * @param {any} [props]

*
* @example
* import { Actribute } from 'deleight/actribute';
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort'
* };
* const act = new Actribute(fallbackProps);
* const prop = act.get(fallbackProps, 'prop1');
* // Fallback
*
* @param {T} obj

@@ -168,0 +209,0 @@ * @param {string} prop

@@ -12,2 +12,3 @@ 'use strict';

* @example
* import { ruleSelectorAll } from 'deleight/appliance';
* const firstSpanRule = ruleSelectorAll('span', document.getElementsByTagName('style')[0], true)[0];

@@ -39,2 +40,3 @@ *

* @example
* import { ruleSelector } from 'deleight/appliance';
* const firstSpanRule = ruleSelector('span', document.getElementsByTagName('style')[0])

@@ -53,2 +55,3 @@ *

* @example
* import { parentSelector } from 'deleight/appliance';
* const removeListener = (e) => {

@@ -77,2 +80,3 @@ * table.removeChild(component.beforeRemove(parentSelector(e.target, 'tr')));

* @example
* import { apply } from 'deleight/appliance';
* apply({

@@ -118,2 +122,3 @@ * main: main => {

* @example
* import { applyTo } from 'deleight/appliance';
* applyTo(Array.from(document.body.children), (...bodyChildren) => console.log(bodyChildren.length));

@@ -120,0 +125,0 @@ *

22

dist/cjs/apriori.js

@@ -12,2 +12,3 @@ 'use strict';

* @example
* import { tag } from 'deleight/apriori';
* const t = tag`I will wait for this ${Promise.resolve("promise")}!!!`

@@ -37,3 +38,4 @@ * // t === 'I will wait for this promise!!!'

* @example
* const t = await apriori.template('I will render this ${"guy"} immediately!!!')();
* import { template } from 'deleight/apriori';
* const t = template('I will render this ${"guy"} immediately!!!')();
* // t === 'I will render this guy immediately!!!'

@@ -55,3 +57,4 @@ *

* @example
* const t = await apriori.asyncTemplate('I will wait for this ${Promise.resolve("promise")}!!!')();
* import { asyncTemplate } from 'deleight/apriori';
* const t = await asyncTemplate('I will wait for this ${Promise.resolve("promise")}!!!')();
* // t === 'I will wait for this promise!!!'

@@ -84,2 +87,3 @@ *

* @example
* import { templates } from 'deleight/apriori';
* const t = arrayTemplate('I will render this ${it}/${other} immediately!!!', ['other'], 'it')([1, 2, 3, 4, 5], '(shared)').join(' & ');

@@ -112,3 +116,4 @@ * // t === 'I will render this 1/(shared) immediately!!! & I will render this 2/(shared) immediately!!! & I will render this 3/(shared) immediately!!! & I will render this 4/(shared) immediately!!! & I will render this 5/(shared) immediately!!!'

* @example
* let t = asyncArrayTemplate('I will async render this ${item}')([1, 2, 3, 4, 5].map(i => Promise.resolve(i)));
* import { asyncTemplates } from 'deleight/apriori';
* let t = asyncTemplates('I will async render this ${item}')([1, 2, 3, 4, 5].map(i => Promise.resolve(i)));
* console.log(t instanceof Promise); // true

@@ -153,3 +158,4 @@ * t = (await t).join(' ')

* @example
* const markup = await apriori.get('./apriori/get.html')
* import { get } from 'deleight/apriori';
* const markup = await get('./something.html')
*

@@ -174,3 +180,4 @@ *

* @example
* const frag1 = apriori.createFragment(`
* import { createFragment } from 'deleight/apriori';
* const frag1 = createFragment(`
* <p>Para 1</p>

@@ -195,5 +202,8 @@ * <p>Para 2</p>

* The names are space-separated just like in a class attribute.
* You can also separate with commma if you prefer.
*
* @example
* import { elements } from 'deleight/apriori';
* const [div, p, span] = elements('div p span');
* const [div2, p2, span2] = elements('div, p, span');
*

@@ -203,3 +213,3 @@ * @param {string} tagNames

function* elements(tagNames) {
for (let tagName of tagNames.split(' '))
for (let tagName of tagNames.replace(',', '').split(' '))
yield document.createElement(tagName.trim());

@@ -206,0 +216,0 @@ }

@@ -13,6 +13,6 @@ 'use strict';

* // Insert a span into all the children of the first main element:
* import {apply} from 'appliance'
* import {insert} from 'domitory'
* import { insert } from 'deleight/domitory';
* const span = document.createElement('span');
* apply({main: main => insert(main.children, main.children.map(() => span.cloneNode())))})
* const main = document.querySelector('main');
* insert(main.children, main.children.map(() => span.cloneNode()))
*

@@ -25,11 +25,10 @@ *

function insert(elements, values, insertWith) {
if (!(elements instanceof Array))
elements = Array.from(elements);
if (!(values instanceof Array))
values = Array.from(values);
if (!insertWith)
insertWith = inserter.append; // the default inserter
let i = 0;
for (let value of values)
insertWith(value, elements[i++]);
let elements2 = elements;
if (!elements2.next)
elements2 = elements[Symbol.iterator]();
for (let value of values) {
insertWith(value, elements2.next().value);
}
return [elements, values];

@@ -65,8 +64,8 @@ }

* // Shuffle the class attributes of all the children of the first main element:
* import {apply} from 'appliance'
* import {set} from 'domitory'
* import {uItems} from 'generational'
* apply({main: main => set(main.children, {_class: uItems(main.children.map(c => c.className))})})
* import { set } from 'deleight/domitory';
* import { uItems } from 'deleight/generational';
* const main = document.querySelector('main');
* const values = uItems(main.children.map(c => c.className));
* set(main.children, {_class: values});
*
*
* @param {(Element|CSSStyleRule)[]} elements

@@ -77,25 +76,41 @@ * @param {ISetMap} values

const localMemberValues = {};
const deps = {};
let memberValues2;
let allValues = new Map();
for (let [key, memberValues] of Object.entries(values)) {
if (!(memberValues instanceof Array))
memberValues = Array.from(memberValues);
localMemberValues[key] = memberValues;
if (allValues.has(memberValues))
deps[key] = allValues.get(memberValues);
else {
memberValues2 = memberValues;
if (!(memberValues2.next))
memberValues2 = memberValues[Symbol.iterator]();
localMemberValues[key] = memberValues2;
allValues.set(memberValues, key);
}
}
if (!(elements instanceof Array))
elements = Array.from(elements);
// if (!(elements instanceof Array)) elements = Array.from(elements);
// we must materialize this first.
let i = 0, memberValue;
for (let [member, memberValues] of Object.entries(localMemberValues)) {
i = 0;
if (member.startsWith("_")) {
member = member.slice(1);
for (memberValue of memberValues) {
elements[i++].setAttribute(member, memberValue);
let member, memberValues, memberValue;
let currentValues = {}, dep;
for (let element of elements) {
for ([member, memberValues] of Object.entries(localMemberValues)) {
memberValue = memberValues.next().value;
currentValues[member] = memberValue;
if (member.startsWith("_")) {
member = member.slice(1);
element.setAttribute(member, memberValue);
}
else {
element[member] = memberValue;
}
}
else {
for (memberValue of memberValues) {
elements[i++][member] = memberValue;
for ([member, dep] of Object.entries(deps)) {
if (member.startsWith("_")) {
member = member.slice(1);
element.setAttribute(member, currentValues[dep]);
}
else {
element[member] = currentValues[dep];
}
}
i++;
}

@@ -107,20 +122,24 @@ return [elements, values];

*
* This will materialize `elements` and `values` unless `lazy`
* is supplied and its value is truthy.
*
* @example
* // Safely shuffle all the children of the first main element:
* import {apply} from 'appliance'
* import {update} from 'domitory'
* import {uItems} from 'generational'
* apply({main: main => update(main.children, uItems(main.children))})
* import { update } from 'deleight/domitory';
* import { uItems } from 'deleight/generational';
* const main = document.querySelector('main');
* update(main.children, uItems(main.children))
*
* @param {Iterable<Node>} elements The nodes to replace.
* @param {Iterable<Node>} values The replacement nodes.
* @param { boolean } [lazy]
*/
function update(elements, values) {
function update(elements, values, lazy) {
let parentNode, tempNode;
const template = document.createComment(""); // document.createElement('template');
const temps = [];
if (!(elements instanceof Array))
if (!lazy) {
elements = Array.from(elements);
if (!(values instanceof Array))
values = Array.from(values);
}
for (let element of elements) {

@@ -133,5 +152,5 @@ parentNode = element.parentNode;

/* at this point we have replaced what we want to replace with temporary values */
let i = 0;
const temps2 = temps.values();
for (let value of values) {
[tempNode, parentNode] = temps[i++];
[tempNode, parentNode] = temps2.next().value;
parentNode?.replaceChild(value, tempNode);

@@ -144,11 +163,16 @@ }

*
* This will materialize `elements` unless `lazy`
* is supplied and its value is truthy.
*
* @example
* // Remove all elements with the 'rem' class
* apply({'.rem': (...elements) => remove(elements)});
* import { update } from 'deleight/domitory';
* const main = document.querySelector('main');
* remoove(main.children);
*
* @param {Iterable<Node>} elements
* @param { boolean } [lazy]
*/
function remove(elements) {
if (!(elements instanceof Array))
elements = Array.from(elements);
function remove(elements, lazy) {
if (!lazy)
elements = [...elements];
for (let element of elements)

@@ -155,0 +179,0 @@ element.parentNode?.removeChild(element);

@@ -7,6 +7,19 @@ 'use strict';

/**
* Base class for EventListener and MatchListener
* Base class for EventListener and MatchListener. This can be used to
* wrap any listeners which will be shared by many elements. Call the
* `listen` or `remove` method to add or remove the listener to/from
* the given elements.
*
* @example
* import { Listener } from 'deleight/eventivity';
* listener = new Listener(() => login(input.value));
* listener.listen('keyup', [window.input1, window.input2])
*
*/
class Listener {
listener;
constructor(listener) {
this.listener = listener;
}
;
listen(eventName, elements, options) {

@@ -44,2 +57,3 @@ for (let element of elements)

* @example
* import { eventListener } from 'deleight/eventivity';
* input.onkeyup = eventListener([onEnter, () => login(input.value), preventDefault]);

@@ -89,7 +103,11 @@ * apply({

* (good practice).
*
* @example
* import { eventListener } from 'deleight/eventivity';
* listener = new EventListener([onEnter, () => login(input.value), preventDefault]);
* listener.listen('keyup', [window.input1, window.input2])
*/
class EventListener extends Listener {
constructor(ops, runContext) {
super();
this.listener = eventListener(ops, runContext);
super(eventListener(ops, runContext));
}

@@ -103,2 +121,3 @@ }

* @example
* import { END } from 'deleight/eventivity';
* const keyEventBreaker = (e: KeyboardEvent) => (e.key !== key)? END: '';

@@ -112,3 +131,4 @@ */

* @example
* table.onclick = matchListener({
* import { matchListener } from 'deleight/eventivity';
* window.mainTable.onclick = matchListener({
* 'a.lbl': e => select(e.target.parentNode.parentNode),

@@ -150,7 +170,15 @@ * 'span.remove': [removeListener, preventDefault, stopPropagation]

* (good practice).
*
* @example
* import { MatchListener } from 'deleight/eventivity';
* const listener = new MatchListener({
* 'a.lbl': e => select(e.target.parentNode.parentNode),
* 'span.remove': [removeListener, preventDefault, stopPropagation]
* }, true);
*
* listener.listen('click', [window.table1, window.table2], eventOptions)
*/
class MatchListener extends Listener {
constructor(matcher, wrapListeners) {
super();
this.listener = matchListener(matcher, wrapListeners);
super(matchListener(matcher, wrapListeners));
}

@@ -162,2 +190,8 @@ }

*
* @example
* import { eventListener, stopPropagation } from 'deleight/eventivity';
* window.firstButton.onclick = eventListener([stopPropagation, (e, runContext) => {
* // handle event here.
* }]);
*
* @param e The event object

@@ -171,2 +205,8 @@ * @returns

*
* @example
* import { eventListener, preventDefault } from 'deleight/eventivity';
* window.firstButton.onclick = eventListener([preventDefault, (e, runContext) => {
* // handle event here.
* }]);
*
* @param e The event object

@@ -183,4 +223,8 @@ * @returns

* @example
* import { eventListener, onKey } from 'deleight/eventivity';
* const aKeyGuard = onKey('a');
* window.firstInput.keyup = eventListener([aKeyGuard, (e, runContext) => {
* // handle event here.
* }]);
*
*
* @returns {Function}

@@ -193,2 +237,9 @@ */

* it has not been triggered by the enter key.
*
* @example
* import { eventListener, onEnter } from 'deleight/eventivity';
* window.firstInput.keyup = eventListener([onEnter, (e, runContext) => {
* // handle event here.
* }]);
*
*/

@@ -195,0 +246,0 @@ const onEnter = onKey(keys.enter);

@@ -7,5 +7,19 @@ 'use strict';

/**
* Forcs any iterable to become an iterator. Will throw
* if not possible.
*
* @example
* import { iter } from 'deleight/generationsl';
* const it = iter([1, 2, 3, 4, 5]);
*
* @param { any } it
*/
function iter(it) {
return (it.next) ? it : it[Symbol.iterator]();
}
/**
* Fast and 'costless' range function for javascript based on generators.
*
* @example
* import { range } from 'deleight/generationsl';
* const arr1000 = [...range(0, 1000)];

@@ -33,3 +47,4 @@ * // creates an array with 1000 items counting from 0 to 999.

* @example
* const tenth = items(arr1000, range(0, 1000, 10));
* import { items, range } from 'deleight/generationsl';
* const tenth = []...items(range(1000), range(0, 1000, 10))];
* // selects every 10th item in the array.

@@ -48,3 +63,8 @@ *

*
* @param {any} what
* @example
* import { repeat } from 'deleight/generationsl';
* const repeated = [...repeat([1, 2, 3], 4)];
* // [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]
*
* @param {Iterable<any>} what
* @param {number} times

@@ -59,35 +79,51 @@ */

/**
* Call to get the length of an object. The object must either
* have a length property of be previously passed in a call to`setLength`.
* Returns an iterator over the next 'count' items of the iterator.
*
* Note that, for performance reasons, this only accepts an
* iterator as the 'it' argument. All the other module functions accept
* iterables.
*
* You can convert any iterable to an iterator using the `iter` funtion
* as shown in the following example.
*
* If a firstValue is specified, it will be yielded first.
*
* @example
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
* import { nextItems, iter } from 'deleight/generationsl';
* const it = iter([1, 'a', 2, 'b', 3, 'c', 4, 'd']);
* const [num, let] = next(it, 2);
*
* @param {any} iter
* @param {Iterator<any>} it
* @param {number} count
* @param { any } [firstValue]
*/
function getLength(iter) {
return iterLengths.get(iter) || iter.length;
function* next(it, count, firstValue) {
let count2 = count;
if (firstValue) {
yield firstValue;
count2--;
}
while (count2-- > 0)
yield it.next().value;
}
/**
* Stores the 'fake' lenghts of iterables passed in calls to `setLength`.
* Can also be modified manually.
*/
const iterLengths = new WeakMap();
/**
* Attaches a 'fake' length to an object (likely iterable or iterator)
* which does not have a length property, so that it can work well with
* functions that use `getLength`.
* Returns an iterator of iterators over the next 'count' items of
* the given iterable
*
* @example
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
* import { next } from 'deleight/generationsl';
* const o1 = [1, 2, 3, 4];
* const o2 = ['a', 'b', 'c', 'd'];
* const zip = group(flat(o1, o2), 2);
*
* @param {any} iter
* @param { Iterable<any> } it
* @param { number } count
*/
function setLength(iter, length) {
iterLengths.set(iter, length);
return iter;
function* group(it, count) {
const it2 = iter(it);
let nextItem = it2.next();
while (!nextItem.done) {
yield [...next(it2, count, nextItem.value)];
nextItem = it2.next();
}
}

@@ -104,2 +140,3 @@ /**

* @example
* import { flat } from 'deleight/generationsl';
* for (let i of flat(range(10, range(15)))) {

@@ -109,21 +146,16 @@ * console.log(i); // 0, 0, 1, 1, 2, 2, .... till smallest iterable (10) is exhausted.

*
* @param {...Iterator<any>} args
* @param {...any[]} args
*/
function* flat(...args) {
const count = getLength(args);
const args2 = [];
let minLength;
for (let arg of args) {
if (!(arg instanceof Array))
arg = Array.from(arg);
args2.push(arg);
if (!minLength || minLength > arg.length)
minLength = arg.length;
}
let j = 0;
while (j < minLength) {
for (let i = 0; i < count; i++) {
yield args2[i][j];
const count = args.length;
args = args.map(arg => iter(arg));
let i, nextItem;
while (true) {
for (i = 0; i < count; i++) {
nextItem = args[i].next();
if (nextItem.done)
return;
else
yield nextItem.value;
}
j++;
}

@@ -135,8 +167,9 @@ }

* @example
* import { uItems } from 'deleight/generationsl';
* const unOrdered = uItems([1, 2, 3, 4]); // [4, 1, 3, 2]
*
* @param {any[]} iter
* @param {Iterable<any>} it
*/
function* uItems(iter) {
const arr = [...iter];
function* uItems(it) {
const arr = [...it];
for (let i = arr.length - 1; i >= 0; i--) {

@@ -146,7 +179,47 @@ yield arr.splice(Math.round(Math.random() * i), 1)[0];

}
/**
* Call to get the length of an object. The object must either
* have a length property of be previously passed in a call to`setLength`.
*
* @example
* import { getLength, setLength } from 'deleight/generationsl';
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
*
* @param {any} it
*/
function getLength(it) {
return iterLengths.get(it) || it.length;
}
/**
* Stores the 'fake' lenghts of iterables passed in calls to `setLength`.
* Can also be modified manually.
*/
const iterLengths = new WeakMap();
/**
* Attaches a 'fake' length to an object (likely iterable or iterator)
* which does not have a length property, so that it can work well with
* functions that use `getLength`.
*
* @example
* import { getLength, setLength } from 'deleight/generationsl';
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
*
* @param {any} it
*/
function setLength(it, length) {
iterLengths.set(it, length);
return it;
}
exports.flat = flat;
exports.getLength = getLength;
exports.group = group;
exports.items = items;
exports.iter = iter;
exports.iterLengths = iterLengths;
exports.next = next;
exports.range = range;

@@ -153,0 +226,0 @@ exports.repeat = repeat;

@@ -23,2 +23,3 @@ 'use strict';

* @example
* import { one } from 'deleight/onetomany';
* const component = one([data(), view(table)], false, [{}]);

@@ -39,2 +40,8 @@ * component.create([10000]);

*
* @example
* import { one, unWrap } from 'deleight/onetomany';
* const o = one([{a: 1}, {a: 2}])
* o.a = [4, 7];
* const many = unWrap(o).many
*
* @param one

@@ -71,4 +78,6 @@ * @returns

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])
* o.set('a', [4, 7]);
*
*
*/

@@ -105,2 +114,3 @@ class One {

* @example
* import { One } from 'deleight/onetomany';
* const loginYes = new One([username => profileView(username)]);

@@ -123,2 +133,3 @@ * loginYes.call([[username]]);

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])

@@ -158,2 +169,3 @@ * o.get('a'); // [1, 2]

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])

@@ -184,2 +196,3 @@ * o.set('a', [4, 7]);

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])

@@ -219,2 +232,3 @@ * o.delete('a');

* @example
* import { One } from 'deleight/onetomany';
* const loginYes = new One([username => profileView(username)]);

@@ -253,12 +267,5 @@ * loginYes.call([[username]]);

}
/**
* Pass this as the first arg in a One call to prevent it from injecting
* a context. This is an alternative to passing a third argument to the
* `call` function
*/
const ignoreContext = Symbol();
exports.One = One;
exports.ignoreContext = ignoreContext;
exports.one = one;
exports.unWrap = unWrap;

@@ -31,2 +31,4 @@ 'use strict';

* @example
* import { Sophistry } from 'deleight/sophistry';
* const mySophistry = new Sophistry();
* const element = apriori.createFragment(apriori.get('markup.html'));

@@ -97,2 +99,4 @@ * const [styles, promises] = mySophistry.process(element);

* @example
* import { Sophistry } from 'deleight/sophistry';
* const mySophistry = new Sophistry();
* const [style, onImport] = mySophistry.import('style.css');

@@ -117,2 +121,4 @@ *

* @example
* import { Sophistry } from 'deleight/sophistry';
* const mySophistry = new Sophistry();
* mySophistry.set('style.css', await apriori.get('new-style.css')); // override everything.

@@ -148,3 +154,4 @@ *

* @example
* const sss = new SophistryStyleSheet(css);
* import { StyleSheet } from 'deleight/sophistry';
* const sss = new StyleSheet(css);
*

@@ -151,0 +158,0 @@ */

@@ -36,2 +36,3 @@ 'use strict';

* @example
* import { With, ASSIGN } from 'deleight/withy';
* const el = With(document.createElement('div')).append().append()[ASSIGN]().append()().append();

@@ -38,0 +39,0 @@ *

@@ -11,4 +11,8 @@ /**

* @example
* import { Actribute } from 'deleight/actribute';
* // initialize:
* const fallbackProps = {prop1: 'Fallback', prop4: 'Last resort'};
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort',
* sig: '$2b$20$o7DWuroOjbA/4LDWIstjueW9Hi6unv4fI0xAit7UQfLw/PI8iPl1y'
* };
* const act = new Actribute(fallbackProps);

@@ -59,4 +63,6 @@ *

*
* When it is used to process markup, attributes with names starting
* with attrPrefix are assumed to be component specifiers.
* It is similar to a Custom Element registry. When used to process
* markup, attributes with names starting with `attrPrefix` are treated
* as component specifiers.
*
* A component specifier is of the form [attrPrefix][componentName]="[propertyName] [propertyName] ..."

@@ -74,2 +80,9 @@ *

*
* @example
* import { Actribute } from 'deleight/actribute';
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort'
* };
* const act = new Actribute(fallbackProps);
*
* @param {any} props The value to assign to the props member.

@@ -87,2 +100,11 @@ * @param {string} attrPrefix The value to assign to attrPrefix. Defaults to 'c-'

*
* @example
* import { Actribute } from 'deleight/actribute';
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort'
* };
* const act = new Actribute(fallbackProps);
* act.register('comp1', (node, prop1) => node.textContent = prop1);
* act.register('comp2', (node, prop2) => node.style.left = prop2);
*
* @param {string} name The component name

@@ -105,2 +127,12 @@ * @param {Function} component The component function

*
* @example
* import { Actribute } from 'deleight/actribute';
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort'
* };
* const act = new Actribute(fallbackProps);
* act.register('comp1', (node, prop1) => node.textContent = prop1);
* act.register('comp2', (node, prop2) => node.style.left = prop2);
* act.process(document.body, {prop2: 1, prop3: 2});
*
* @param {HTMLElement} element

@@ -140,2 +172,3 @@ * @param {any} [props]

* @example
* import { ruleSelectorAll } from 'deleight/appliance';
* const firstSpanRule = ruleSelectorAll('span', document.getElementsByTagName('style')[0], true)[0];

@@ -153,2 +186,3 @@ *

* @example
* import { ruleSelector } from 'deleight/appliance';
* const firstSpanRule = ruleSelector('span', document.getElementsByTagName('style')[0])

@@ -165,2 +199,3 @@ *

* @example
* import { parentSelector } from 'deleight/appliance';
* const removeListener = (e) => {

@@ -184,2 +219,3 @@ * table.removeChild(component.beforeRemove(parentSelector(e.target, 'tr')));

* @example
* import { apply } from 'deleight/appliance';
* apply({

@@ -206,2 +242,3 @@ * main: main => {

* @example
* import { applyTo } from 'deleight/appliance';
* applyTo(Array.from(document.body.children), (...bodyChildren) => console.log(bodyChildren.length));

@@ -224,2 +261,3 @@ *

* @example
* import { tag } from 'deleight/apriori';
* const t = tag`I will wait for this ${Promise.resolve("promise")}!!!`

@@ -238,3 +276,4 @@ * // t === 'I will wait for this promise!!!'

* @example
* const t = await apriori.template('I will render this ${"guy"} immediately!!!')();
* import { template } from 'deleight/apriori';
* const t = template('I will render this ${"guy"} immediately!!!')();
* // t === 'I will render this guy immediately!!!'

@@ -252,3 +291,4 @@ *

* @example
* const t = await apriori.asyncTemplate('I will wait for this ${Promise.resolve("promise")}!!!')();
* import { asyncTemplate } from 'deleight/apriori';
* const t = await asyncTemplate('I will wait for this ${Promise.resolve("promise")}!!!')();
* // t === 'I will wait for this promise!!!'

@@ -282,2 +322,3 @@ *

* @example
* import { templates } from 'deleight/apriori';
* const t = arrayTemplate('I will render this ${it}/${other} immediately!!!', ['other'], 'it')([1, 2, 3, 4, 5], '(shared)').join(' & ');

@@ -300,3 +341,4 @@ * // t === 'I will render this 1/(shared) immediately!!! & I will render this 2/(shared) immediately!!! & I will render this 3/(shared) immediately!!! & I will render this 4/(shared) immediately!!! & I will render this 5/(shared) immediately!!!'

* @example
* let t = asyncArrayTemplate('I will async render this ${item}')([1, 2, 3, 4, 5].map(i => Promise.resolve(i)));
* import { asyncTemplates } from 'deleight/apriori';
* let t = asyncTemplates('I will async render this ${item}')([1, 2, 3, 4, 5].map(i => Promise.resolve(i)));
* console.log(t instanceof Promise); // true

@@ -320,3 +362,4 @@ * t = (await t).join(' ')

* @example
* const markup = await apriori.get('./apriori/get.html')
* import { get } from 'deleight/apriori';
* const markup = await get('./something.html')
*

@@ -336,3 +379,4 @@ *

* @example
* const frag1 = apriori.createFragment(`
* import { createFragment } from 'deleight/apriori';
* const frag1 = createFragment(`
* <p>Para 1</p>

@@ -350,5 +394,8 @@ * <p>Para 2</p>

* The names are space-separated just like in a class attribute.
* You can also separate with commma if you prefer.
*
* @example
* import { elements } from 'deleight/apriori';
* const [div, p, span] = elements('div p span');
* const [div2, p2, span2] = elements('div, p, span');
*

@@ -378,6 +425,6 @@ * @param {string} tagNames

* // Insert a span into all the children of the first main element:
* import {apply} from 'appliance'
* import {insert} from 'domitory'
* import { insert } from 'deleight/domitory';
* const span = document.createElement('span');
* apply({main: main => insert(main.children, main.children.map(() => span.cloneNode())))})
* const main = document.querySelector('main');
* insert(main.children, main.children.map(() => span.cloneNode()))
*

@@ -421,3 +468,3 @@ *

interface ISetMap {
[key: string]: any[];
[key: string]: Iterable<any>;
}

@@ -431,8 +478,8 @@ /**

* // Shuffle the class attributes of all the children of the first main element:
* import {apply} from 'appliance'
* import {set} from 'domitory'
* import {uItems} from 'generational'
* apply({main: main => set(main.children, {_class: uItems(main.children.map(c => c.className))})})
* import { set } from 'deleight/domitory';
* import { uItems } from 'deleight/generational';
* const main = document.querySelector('main');
* const values = uItems(main.children.map(c => c.className));
* set(main.children, {_class: values});
*
*
* @param {(Element|CSSStyleRule)[]} elements

@@ -445,23 +492,32 @@ * @param {ISetMap} values

*
* This will materialize `elements` and `values` unless `lazy`
* is supplied and its value is truthy.
*
* @example
* // Safely shuffle all the children of the first main element:
* import {apply} from 'appliance'
* import {update} from 'domitory'
* import {uItems} from 'generational'
* apply({main: main => update(main.children, uItems(main.children))})
* import { update } from 'deleight/domitory';
* import { uItems } from 'deleight/generational';
* const main = document.querySelector('main');
* update(main.children, uItems(main.children))
*
* @param {Iterable<Node>} elements The nodes to replace.
* @param {Iterable<Node>} values The replacement nodes.
* @param { boolean } [lazy]
*/
declare function update(elements: Iterable<Node>, values: Iterable<Node>): [Iterable<Node>, Iterable<Node>];
declare function update(elements: Iterable<Node>, values: Iterable<Node>, lazy?: boolean): [Iterable<Node>, Iterable<Node>];
/**
* Remove the elements from their parent nodes.
*
* This will materialize `elements` unless `lazy`
* is supplied and its value is truthy.
*
* @example
* // Remove all elements with the 'rem' class
* apply({'.rem': (...elements) => remove(elements)});
* import { update } from 'deleight/domitory';
* const main = document.querySelector('main');
* remoove(main.children);
*
* @param {Iterable<Node>} elements
* @param { boolean } [lazy]
*/
declare function remove(elements: Iterable<Node>): Iterable<Node>;
declare function remove(elements: Iterable<Node>, lazy?: boolean): Iterable<Node>;

@@ -472,6 +528,16 @@ /**

/**
* Base class for EventListener and MatchListener
* Base class for EventListener and MatchListener. This can be used to
* wrap any listeners which will be shared by many elements. Call the
* `listen` or `remove` method to add or remove the listener to/from
* the given elements.
*
* @example
* import { Listener } from 'deleight/eventivity';
* listener = new Listener(() => login(input.value));
* listener.listen('keyup', [window.input1, window.input2])
*
*/
declare class Listener {
listener: EventListenerOrEventListenerObject;
constructor(listener: EventListenerOrEventListenerObject);
listen(eventName: string, elements: EventTarget[], options?: boolean | AddEventListenerOptions): void;

@@ -481,3 +547,3 @@ remove(eventName: string, ...elements: EventTarget[]): void;

/**
* Object mapping element mapping strings to event handler functions.
* Object mapping element matching strings to event handler functions.
* The matching strings (keys) are used to match event targets to trigger

@@ -512,2 +578,3 @@ * the invocation of their associated handler functions.

* @example
* import { eventListener } from 'deleight/eventivity';
* input.onkeyup = eventListener([onEnter, () => login(input.value), preventDefault]);

@@ -532,2 +599,7 @@ * apply({

* (good practice).
*
* @example
* import { eventListener } from 'deleight/eventivity';
* listener = new EventListener([onEnter, () => login(input.value), preventDefault]);
* listener.listen('keyup', [window.input1, window.input2])
*/

@@ -543,2 +615,3 @@ declare class EventListener extends Listener {

* @example
* import { END } from 'deleight/eventivity';
* const keyEventBreaker = (e: KeyboardEvent) => (e.key !== key)? END: '';

@@ -552,3 +625,4 @@ */

* @example
* table.onclick = matchListener({
* import { matchListener } from 'deleight/eventivity';
* window.mainTable.onclick = matchListener({
* 'a.lbl': e => select(e.target.parentNode.parentNode),

@@ -565,3 +639,4 @@ * 'span.remove': [removeListener, preventDefault, stopPropagation]

/**
* An event target which may have a 'matches' method.
* An event target which may have a 'matches' method. This includes most
* standard HTML elements.
*/

@@ -577,2 +652,11 @@ interface IMatchEventTarget extends EventTarget {

* (good practice).
*
* @example
* import { MatchListener } from 'deleight/eventivity';
* const listener = new MatchListener({
* 'a.lbl': e => select(e.target.parentNode.parentNode),
* 'span.remove': [removeListener, preventDefault, stopPropagation]
* }, true);
*
* listener.listen('click', [window.table1, window.table2], eventOptions)
*/

@@ -586,2 +670,8 @@ declare class MatchListener extends Listener {

*
* @example
* import { eventListener, stopPropagation } from 'deleight/eventivity';
* window.firstButton.onclick = eventListener([stopPropagation, (e, runContext) => {
* // handle event here.
* }]);
*
* @param e The event object

@@ -597,2 +687,8 @@ * @returns

*
* @example
* import { eventListener, preventDefault } from 'deleight/eventivity';
* window.firstButton.onclick = eventListener([preventDefault, (e, runContext) => {
* // handle event here.
* }]);
*
* @param e The event object

@@ -611,4 +707,8 @@ * @returns

* @example
* import { eventListener, onKey } from 'deleight/eventivity';
* const aKeyGuard = onKey('a');
* window.firstInput.keyup = eventListener([aKeyGuard, (e, runContext) => {
* // handle event here.
* }]);
*
*
* @returns {Function}

@@ -623,2 +723,9 @@ */

* it has not been triggered by the enter key.
*
* @example
* import { eventListener, onEnter } from 'deleight/eventivity';
* window.firstInput.keyup = eventListener([onEnter, (e, runContext) => {
* // handle event here.
* }]);
*
*/

@@ -631,5 +738,17 @@ declare const onEnter: (e: KeyboardEvent) => "" | typeof END;

/**
* Forcs any iterable to become an iterator. Will throw
* if not possible.
*
* @example
* import { iter } from 'deleight/generationsl';
* const it = iter([1, 2, 3, 4, 5]);
*
* @param { any } it
*/
declare function iter(it: any): Iterator<any>;
/**
* Fast and 'costless' range function for javascript based on generators.
*
* @example
* import { range } from 'deleight/generationsl';
* const arr1000 = [...range(0, 1000)];

@@ -648,3 +767,4 @@ * // creates an array with 1000 items counting from 0 to 999.

* @example
* const tenth = items(arr1000, range(0, 1000, 10));
* import { items, range } from 'deleight/generationsl';
* const tenth = []...items(range(1000), range(0, 1000, 10))];
* // selects every 10th item in the array.

@@ -660,36 +780,47 @@ *

*
* @param {any} what
* @example
* import { repeat } from 'deleight/generationsl';
* const repeated = [...repeat([1, 2, 3], 4)];
* // [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]
*
* @param {Iterable<any>} what
* @param {number} times
*/
declare function repeat(what: any, times: number): Generator<any, void, unknown>;
declare function repeat(what: Iterable<any>, times: number): Generator<any, void, unknown>;
/**
* Call to get the length of an object. The object must either
* have a length property of be previously passed in a call to`setLength`.
* Returns an iterator over the next 'count' items of the iterator.
*
* Note that, for performance reasons, this only accepts an
* iterator as the 'it' argument. All the other module functions accept
* iterables.
*
* You can convert any iterable to an iterator using the `iter` funtion
* as shown in the following example.
*
* If a firstValue is specified, it will be yielded first.
*
* @example
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
* import { nextItems, iter } from 'deleight/generationsl';
* const it = iter([1, 'a', 2, 'b', 3, 'c', 4, 'd']);
* const [num, let] = next(it, 2);
*
* @param {any} iter
* @param {Iterator<any>} it
* @param {number} count
* @param { any } [firstValue]
*/
declare function getLength(iter: any): number;
declare function next(it: Iterator<any>, count: number, firstValue?: any): Generator<any, void, unknown>;
/**
* Stores the 'fake' lenghts of iterables passed in calls to `setLength`.
* Can also be modified manually.
*/
declare const iterLengths: WeakMap<any, number>;
/**
* Attaches a 'fake' length to an object (likely iterable or iterator)
* which does not have a length property, so that it can work well with
* functions that use `getLength`.
* Returns an iterator of iterators over the next 'count' items of
* the given iterable
*
* @example
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
* import { next } from 'deleight/generationsl';
* const o1 = [1, 2, 3, 4];
* const o2 = ['a', 'b', 'c', 'd'];
* const zip = group(flat(o1, o2), 2);
*
* @param {any} iter
* @param { Iterable<any> } it
* @param { number } count
*/
declare function setLength(iter: any, length: number): any;
declare function group(it: Iterable<any>, count: number): Generator<any[], void, unknown>;
/**

@@ -705,2 +836,3 @@ * Returns an iterator over the items of all the input iterators, starting from

* @example
* import { flat } from 'deleight/generationsl';
* for (let i of flat(range(10, range(15)))) {

@@ -710,3 +842,3 @@ * console.log(i); // 0, 0, 1, 1, 2, 2, .... till smallest iterable (10) is exhausted.

*
* @param {...Iterator<any>} args
* @param {...any[]} args
*/

@@ -718,7 +850,40 @@ declare function flat(...args: any[]): Generator<any, void, unknown>;

* @example
* import { uItems } from 'deleight/generationsl';
* const unOrdered = uItems([1, 2, 3, 4]); // [4, 1, 3, 2]
*
* @param {any[]} iter
* @param {Iterable<any>} it
*/
declare function uItems(iter: any[]): Generator<any, void, unknown>;
declare function uItems(it: Iterable<any>): Generator<any, void, unknown>;
/**
* Call to get the length of an object. The object must either
* have a length property of be previously passed in a call to`setLength`.
*
* @example
* import { getLength, setLength } from 'deleight/generationsl';
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
*
* @param {any} it
*/
declare function getLength(it: any): number;
/**
* Stores the 'fake' lenghts of iterables passed in calls to `setLength`.
* Can also be modified manually.
*/
declare const iterLengths: WeakMap<any, number>;
/**
* Attaches a 'fake' length to an object (likely iterable or iterator)
* which does not have a length property, so that it can work well with
* functions that use `getLength`.
*
* @example
* import { getLength, setLength } from 'deleight/generationsl';
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
*
* @param {any} it
*/
declare function setLength(it: any, length: number): any;

@@ -745,2 +910,3 @@ /**

* @example
* import { one } from 'deleight/onetomany';
* const component = one([data(), view(table)], false, [{}]);

@@ -758,2 +924,8 @@ * component.create([10000]);

*
* @example
* import { one, unWrap } from 'deleight/onetomany';
* const o = one([{a: 1}, {a: 2}])
* o.a = [4, 7];
* const many = unWrap(o).many
*
* @param one

@@ -773,4 +945,6 @@ * @returns

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])
* o.set('a', [4, 7]);
*
*
*/

@@ -807,2 +981,3 @@ declare class One {

* @example
* import { One } from 'deleight/onetomany';
* const loginYes = new One([username => profileView(username)]);

@@ -821,2 +996,3 @@ * loginYes.call([[username]]);

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])

@@ -835,2 +1011,3 @@ * o.get('a'); // [1, 2]

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])

@@ -847,2 +1024,3 @@ * o.set('a', [4, 7]);

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])

@@ -879,2 +1057,3 @@ * o.delete('a');

* @example
* import { One } from 'deleight/onetomany';
* const loginYes = new One([username => profileView(username)]);

@@ -891,8 +1070,2 @@ * loginYes.call([[username]]);

}
/**
* Pass this as the first arg in a One call to prevent it from injecting
* a context. This is an alternative to passing a third argument to the
* `call` function
*/
declare const ignoreContext: unique symbol;

@@ -927,2 +1100,4 @@ /**

* @example
* import { Sophistry } from 'deleight/sophistry';
* const mySophistry = new Sophistry();
* const element = apriori.createFragment(apriori.get('markup.html'));

@@ -945,2 +1120,4 @@ * const [styles, promises] = mySophistry.process(element);

* @example
* import { Sophistry } from 'deleight/sophistry';
* const mySophistry = new Sophistry();
* const [style, onImport] = mySophistry.import('style.css');

@@ -957,2 +1134,4 @@ *

* @example
* import { Sophistry } from 'deleight/sophistry';
* const mySophistry = new Sophistry();
* mySophistry.set('style.css', await apriori.get('new-style.css')); // override everything.

@@ -971,3 +1150,4 @@ *

* @example
* const sss = new SophistryStyleSheet(css);
* import { StyleSheet } from 'deleight/sophistry';
* const sss = new StyleSheet(css);
*

@@ -1083,2 +1263,3 @@ */

* @example
* import { With, ASSIGN } from 'deleight/withy';
* const el = With(document.createElement('div')).append().append()[ASSIGN]().append()().append();

@@ -1091,2 +1272,2 @@ *

export { ASSIGN, Actribute, END, EventListener, type IAnyFunction, type IApplyMap, type IAsyncTemplates, type IInserter, type IMatchEventTarget, type IMatcher, type IOneConstructor, type IRecursive, type IRecursiveProp, type IRecursiveSetProp, type ISetMap, type ITemplates, Listener, MatchListener, One, SET, Sophistry, StyleSheet, WITH, With, apply, applyTo, asyncTemplate, asyncTemplates, createFragment, elements, eventListener, flat, get, getLength, ignoreContext, insert, inserter, items, iterLengths, keys, matchListener, onEnter, onKey, one, parentSelector, preventDefault, range, remove, repeat, ruleSelector, ruleSelectorAll, set, setLength, stopPropagation, tag, template, templates, uItems, unWrap, update };
export { ASSIGN, Actribute, END, EventListener, type IAnyFunction, type IApplyMap, type IAsyncTemplates, type IInserter, type IMatchEventTarget, type IMatcher, type IOneConstructor, type IRecursive, type IRecursiveProp, type IRecursiveSetProp, type ISetMap, type ITemplates, Listener, MatchListener, One, SET, Sophistry, StyleSheet, WITH, With, apply, applyTo, asyncTemplate, asyncTemplates, createFragment, elements, eventListener, flat, get, getLength, group, insert, inserter, items, iter, iterLengths, keys, matchListener, next, onEnter, onKey, one, parentSelector, preventDefault, range, remove, repeat, ruleSelector, ruleSelectorAll, set, setLength, stopPropagation, tag, template, templates, uItems, unWrap, update };

@@ -11,4 +11,8 @@ /**

* @example
* import { Actribute } from 'deleight/actribute';
* // initialize:
* const fallbackProps = {prop1: 'Fallback', prop4: 'Last resort'};
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort',
* sig: '$2b$20$o7DWuroOjbA/4LDWIstjueW9Hi6unv4fI0xAit7UQfLw/PI8iPl1y'
* };
* const act = new Actribute(fallbackProps);

@@ -57,4 +61,6 @@ *

*
* When it is used to process markup, attributes with names starting
* with attrPrefix are assumed to be component specifiers.
* It is similar to a Custom Element registry. When used to process
* markup, attributes with names starting with `attrPrefix` are treated
* as component specifiers.
*
* A component specifier is of the form [attrPrefix][componentName]="[propertyName] [propertyName] ..."

@@ -72,2 +78,9 @@ *

*
* @example
* import { Actribute } from 'deleight/actribute';
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort'
* };
* const act = new Actribute(fallbackProps);
*
* @param {any} props The value to assign to the props member.

@@ -88,2 +101,11 @@ * @param {string} attrPrefix The value to assign to attrPrefix. Defaults to 'c-'

*
* @example
* import { Actribute } from 'deleight/actribute';
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort'
* };
* const act = new Actribute(fallbackProps);
* act.register('comp1', (node, prop1) => node.textContent = prop1);
* act.register('comp2', (node, prop2) => node.style.left = prop2);
*
* @param {string} name The component name

@@ -109,2 +131,12 @@ * @param {Function} component The component function

*
* @example
* import { Actribute } from 'deleight/actribute';
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort'
* };
* const act = new Actribute(fallbackProps);
* act.register('comp1', (node, prop1) => node.textContent = prop1);
* act.register('comp2', (node, prop2) => node.style.left = prop2);
* act.process(document.body, {prop2: 1, prop3: 2});
*
* @param {HTMLElement} element

@@ -164,2 +196,11 @@ * @param {any} [props]

*
* @example
* import { Actribute } from 'deleight/actribute';
* const fallbackProps = {
* prop1: 'Fallback', prop4: 'Last resort'
* };
* const act = new Actribute(fallbackProps);
* const prop = act.get(fallbackProps, 'prop1');
* // Fallback
*
* @param {T} obj

@@ -166,0 +207,0 @@ * @param {string} prop

@@ -10,2 +10,3 @@ /**

* @example
* import { ruleSelectorAll } from 'deleight/appliance';
* const firstSpanRule = ruleSelectorAll('span', document.getElementsByTagName('style')[0], true)[0];

@@ -37,2 +38,3 @@ *

* @example
* import { ruleSelector } from 'deleight/appliance';
* const firstSpanRule = ruleSelector('span', document.getElementsByTagName('style')[0])

@@ -51,2 +53,3 @@ *

* @example
* import { parentSelector } from 'deleight/appliance';
* const removeListener = (e) => {

@@ -75,2 +78,3 @@ * table.removeChild(component.beforeRemove(parentSelector(e.target, 'tr')));

* @example
* import { apply } from 'deleight/appliance';
* apply({

@@ -116,2 +120,3 @@ * main: main => {

* @example
* import { applyTo } from 'deleight/appliance';
* applyTo(Array.from(document.body.children), (...bodyChildren) => console.log(bodyChildren.length));

@@ -118,0 +123,0 @@ *

@@ -10,2 +10,3 @@ /**

* @example
* import { tag } from 'deleight/apriori';
* const t = tag`I will wait for this ${Promise.resolve("promise")}!!!`

@@ -35,3 +36,4 @@ * // t === 'I will wait for this promise!!!'

* @example
* const t = await apriori.template('I will render this ${"guy"} immediately!!!')();
* import { template } from 'deleight/apriori';
* const t = template('I will render this ${"guy"} immediately!!!')();
* // t === 'I will render this guy immediately!!!'

@@ -53,3 +55,4 @@ *

* @example
* const t = await apriori.asyncTemplate('I will wait for this ${Promise.resolve("promise")}!!!')();
* import { asyncTemplate } from 'deleight/apriori';
* const t = await asyncTemplate('I will wait for this ${Promise.resolve("promise")}!!!')();
* // t === 'I will wait for this promise!!!'

@@ -82,2 +85,3 @@ *

* @example
* import { templates } from 'deleight/apriori';
* const t = arrayTemplate('I will render this ${it}/${other} immediately!!!', ['other'], 'it')([1, 2, 3, 4, 5], '(shared)').join(' & ');

@@ -110,3 +114,4 @@ * // t === 'I will render this 1/(shared) immediately!!! & I will render this 2/(shared) immediately!!! & I will render this 3/(shared) immediately!!! & I will render this 4/(shared) immediately!!! & I will render this 5/(shared) immediately!!!'

* @example
* let t = asyncArrayTemplate('I will async render this ${item}')([1, 2, 3, 4, 5].map(i => Promise.resolve(i)));
* import { asyncTemplates } from 'deleight/apriori';
* let t = asyncTemplates('I will async render this ${item}')([1, 2, 3, 4, 5].map(i => Promise.resolve(i)));
* console.log(t instanceof Promise); // true

@@ -151,3 +156,4 @@ * t = (await t).join(' ')

* @example
* const markup = await apriori.get('./apriori/get.html')
* import { get } from 'deleight/apriori';
* const markup = await get('./something.html')
*

@@ -172,3 +178,4 @@ *

* @example
* const frag1 = apriori.createFragment(`
* import { createFragment } from 'deleight/apriori';
* const frag1 = createFragment(`
* <p>Para 1</p>

@@ -193,5 +200,8 @@ * <p>Para 2</p>

* The names are space-separated just like in a class attribute.
* You can also separate with commma if you prefer.
*
* @example
* import { elements } from 'deleight/apriori';
* const [div, p, span] = elements('div p span');
* const [div2, p2, span2] = elements('div, p, span');
*

@@ -201,3 +211,3 @@ * @param {string} tagNames

function* elements(tagNames) {
for (let tagName of tagNames.split(' '))
for (let tagName of tagNames.replace(',', '').split(' '))
yield document.createElement(tagName.trim());

@@ -204,0 +214,0 @@ }

@@ -11,6 +11,6 @@ /**

* // Insert a span into all the children of the first main element:
* import {apply} from 'appliance'
* import {insert} from 'domitory'
* import { insert } from 'deleight/domitory';
* const span = document.createElement('span');
* apply({main: main => insert(main.children, main.children.map(() => span.cloneNode())))})
* const main = document.querySelector('main');
* insert(main.children, main.children.map(() => span.cloneNode()))
*

@@ -23,11 +23,10 @@ *

function insert(elements, values, insertWith) {
if (!(elements instanceof Array))
elements = Array.from(elements);
if (!(values instanceof Array))
values = Array.from(values);
if (!insertWith)
insertWith = inserter.append; // the default inserter
let i = 0;
for (let value of values)
insertWith(value, elements[i++]);
let elements2 = elements;
if (!elements2.next)
elements2 = elements[Symbol.iterator]();
for (let value of values) {
insertWith(value, elements2.next().value);
}
return [elements, values];

@@ -63,8 +62,8 @@ }

* // Shuffle the class attributes of all the children of the first main element:
* import {apply} from 'appliance'
* import {set} from 'domitory'
* import {uItems} from 'generational'
* apply({main: main => set(main.children, {_class: uItems(main.children.map(c => c.className))})})
* import { set } from 'deleight/domitory';
* import { uItems } from 'deleight/generational';
* const main = document.querySelector('main');
* const values = uItems(main.children.map(c => c.className));
* set(main.children, {_class: values});
*
*
* @param {(Element|CSSStyleRule)[]} elements

@@ -75,25 +74,41 @@ * @param {ISetMap} values

const localMemberValues = {};
const deps = {};
let memberValues2;
let allValues = new Map();
for (let [key, memberValues] of Object.entries(values)) {
if (!(memberValues instanceof Array))
memberValues = Array.from(memberValues);
localMemberValues[key] = memberValues;
if (allValues.has(memberValues))
deps[key] = allValues.get(memberValues);
else {
memberValues2 = memberValues;
if (!(memberValues2.next))
memberValues2 = memberValues[Symbol.iterator]();
localMemberValues[key] = memberValues2;
allValues.set(memberValues, key);
}
}
if (!(elements instanceof Array))
elements = Array.from(elements);
// if (!(elements instanceof Array)) elements = Array.from(elements);
// we must materialize this first.
let i = 0, memberValue;
for (let [member, memberValues] of Object.entries(localMemberValues)) {
i = 0;
if (member.startsWith("_")) {
member = member.slice(1);
for (memberValue of memberValues) {
elements[i++].setAttribute(member, memberValue);
let member, memberValues, memberValue;
let currentValues = {}, dep;
for (let element of elements) {
for ([member, memberValues] of Object.entries(localMemberValues)) {
memberValue = memberValues.next().value;
currentValues[member] = memberValue;
if (member.startsWith("_")) {
member = member.slice(1);
element.setAttribute(member, memberValue);
}
else {
element[member] = memberValue;
}
}
else {
for (memberValue of memberValues) {
elements[i++][member] = memberValue;
for ([member, dep] of Object.entries(deps)) {
if (member.startsWith("_")) {
member = member.slice(1);
element.setAttribute(member, currentValues[dep]);
}
else {
element[member] = currentValues[dep];
}
}
i++;
}

@@ -105,20 +120,24 @@ return [elements, values];

*
* This will materialize `elements` and `values` unless `lazy`
* is supplied and its value is truthy.
*
* @example
* // Safely shuffle all the children of the first main element:
* import {apply} from 'appliance'
* import {update} from 'domitory'
* import {uItems} from 'generational'
* apply({main: main => update(main.children, uItems(main.children))})
* import { update } from 'deleight/domitory';
* import { uItems } from 'deleight/generational';
* const main = document.querySelector('main');
* update(main.children, uItems(main.children))
*
* @param {Iterable<Node>} elements The nodes to replace.
* @param {Iterable<Node>} values The replacement nodes.
* @param { boolean } [lazy]
*/
function update(elements, values) {
function update(elements, values, lazy) {
let parentNode, tempNode;
const template = document.createComment(""); // document.createElement('template');
const temps = [];
if (!(elements instanceof Array))
if (!lazy) {
elements = Array.from(elements);
if (!(values instanceof Array))
values = Array.from(values);
}
for (let element of elements) {

@@ -131,5 +150,5 @@ parentNode = element.parentNode;

/* at this point we have replaced what we want to replace with temporary values */
let i = 0;
const temps2 = temps.values();
for (let value of values) {
[tempNode, parentNode] = temps[i++];
[tempNode, parentNode] = temps2.next().value;
parentNode?.replaceChild(value, tempNode);

@@ -142,11 +161,16 @@ }

*
* This will materialize `elements` unless `lazy`
* is supplied and its value is truthy.
*
* @example
* // Remove all elements with the 'rem' class
* apply({'.rem': (...elements) => remove(elements)});
* import { update } from 'deleight/domitory';
* const main = document.querySelector('main');
* remoove(main.children);
*
* @param {Iterable<Node>} elements
* @param { boolean } [lazy]
*/
function remove(elements) {
if (!(elements instanceof Array))
elements = Array.from(elements);
function remove(elements, lazy) {
if (!lazy)
elements = [...elements];
for (let element of elements)

@@ -153,0 +177,0 @@ element.parentNode?.removeChild(element);

@@ -5,6 +5,19 @@ /**

/**
* Base class for EventListener and MatchListener
* Base class for EventListener and MatchListener. This can be used to
* wrap any listeners which will be shared by many elements. Call the
* `listen` or `remove` method to add or remove the listener to/from
* the given elements.
*
* @example
* import { Listener } from 'deleight/eventivity';
* listener = new Listener(() => login(input.value));
* listener.listen('keyup', [window.input1, window.input2])
*
*/
class Listener {
listener;
constructor(listener) {
this.listener = listener;
}
;
listen(eventName, elements, options) {

@@ -42,2 +55,3 @@ for (let element of elements)

* @example
* import { eventListener } from 'deleight/eventivity';
* input.onkeyup = eventListener([onEnter, () => login(input.value), preventDefault]);

@@ -87,7 +101,11 @@ * apply({

* (good practice).
*
* @example
* import { eventListener } from 'deleight/eventivity';
* listener = new EventListener([onEnter, () => login(input.value), preventDefault]);
* listener.listen('keyup', [window.input1, window.input2])
*/
class EventListener extends Listener {
constructor(ops, runContext) {
super();
this.listener = eventListener(ops, runContext);
super(eventListener(ops, runContext));
}

@@ -101,2 +119,3 @@ }

* @example
* import { END } from 'deleight/eventivity';
* const keyEventBreaker = (e: KeyboardEvent) => (e.key !== key)? END: '';

@@ -110,3 +129,4 @@ */

* @example
* table.onclick = matchListener({
* import { matchListener } from 'deleight/eventivity';
* window.mainTable.onclick = matchListener({
* 'a.lbl': e => select(e.target.parentNode.parentNode),

@@ -148,7 +168,15 @@ * 'span.remove': [removeListener, preventDefault, stopPropagation]

* (good practice).
*
* @example
* import { MatchListener } from 'deleight/eventivity';
* const listener = new MatchListener({
* 'a.lbl': e => select(e.target.parentNode.parentNode),
* 'span.remove': [removeListener, preventDefault, stopPropagation]
* }, true);
*
* listener.listen('click', [window.table1, window.table2], eventOptions)
*/
class MatchListener extends Listener {
constructor(matcher, wrapListeners) {
super();
this.listener = matchListener(matcher, wrapListeners);
super(matchListener(matcher, wrapListeners));
}

@@ -160,2 +188,8 @@ }

*
* @example
* import { eventListener, stopPropagation } from 'deleight/eventivity';
* window.firstButton.onclick = eventListener([stopPropagation, (e, runContext) => {
* // handle event here.
* }]);
*
* @param e The event object

@@ -169,2 +203,8 @@ * @returns

*
* @example
* import { eventListener, preventDefault } from 'deleight/eventivity';
* window.firstButton.onclick = eventListener([preventDefault, (e, runContext) => {
* // handle event here.
* }]);
*
* @param e The event object

@@ -181,4 +221,8 @@ * @returns

* @example
* import { eventListener, onKey } from 'deleight/eventivity';
* const aKeyGuard = onKey('a');
* window.firstInput.keyup = eventListener([aKeyGuard, (e, runContext) => {
* // handle event here.
* }]);
*
*
* @returns {Function}

@@ -191,2 +235,9 @@ */

* it has not been triggered by the enter key.
*
* @example
* import { eventListener, onEnter } from 'deleight/eventivity';
* window.firstInput.keyup = eventListener([onEnter, (e, runContext) => {
* // handle event here.
* }]);
*
*/

@@ -193,0 +244,0 @@ const onEnter = onKey(keys.enter);

@@ -5,5 +5,19 @@ /**

/**
* Forcs any iterable to become an iterator. Will throw
* if not possible.
*
* @example
* import { iter } from 'deleight/generationsl';
* const it = iter([1, 2, 3, 4, 5]);
*
* @param { any } it
*/
function iter(it) {
return (it.next) ? it : it[Symbol.iterator]();
}
/**
* Fast and 'costless' range function for javascript based on generators.
*
* @example
* import { range } from 'deleight/generationsl';
* const arr1000 = [...range(0, 1000)];

@@ -31,3 +45,4 @@ * // creates an array with 1000 items counting from 0 to 999.

* @example
* const tenth = items(arr1000, range(0, 1000, 10));
* import { items, range } from 'deleight/generationsl';
* const tenth = []...items(range(1000), range(0, 1000, 10))];
* // selects every 10th item in the array.

@@ -46,3 +61,8 @@ *

*
* @param {any} what
* @example
* import { repeat } from 'deleight/generationsl';
* const repeated = [...repeat([1, 2, 3], 4)];
* // [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]
*
* @param {Iterable<any>} what
* @param {number} times

@@ -57,35 +77,51 @@ */

/**
* Call to get the length of an object. The object must either
* have a length property of be previously passed in a call to`setLength`.
* Returns an iterator over the next 'count' items of the iterator.
*
* Note that, for performance reasons, this only accepts an
* iterator as the 'it' argument. All the other module functions accept
* iterables.
*
* You can convert any iterable to an iterator using the `iter` funtion
* as shown in the following example.
*
* If a firstValue is specified, it will be yielded first.
*
* @example
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
* import { nextItems, iter } from 'deleight/generationsl';
* const it = iter([1, 'a', 2, 'b', 3, 'c', 4, 'd']);
* const [num, let] = next(it, 2);
*
* @param {any} iter
* @param {Iterator<any>} it
* @param {number} count
* @param { any } [firstValue]
*/
function getLength(iter) {
return iterLengths.get(iter) || iter.length;
function* next(it, count, firstValue) {
let count2 = count;
if (firstValue) {
yield firstValue;
count2--;
}
while (count2-- > 0)
yield it.next().value;
}
/**
* Stores the 'fake' lenghts of iterables passed in calls to `setLength`.
* Can also be modified manually.
*/
const iterLengths = new WeakMap();
/**
* Attaches a 'fake' length to an object (likely iterable or iterator)
* which does not have a length property, so that it can work well with
* functions that use `getLength`.
* Returns an iterator of iterators over the next 'count' items of
* the given iterable
*
* @example
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
* import { next } from 'deleight/generationsl';
* const o1 = [1, 2, 3, 4];
* const o2 = ['a', 'b', 'c', 'd'];
* const zip = group(flat(o1, o2), 2);
*
* @param {any} iter
* @param { Iterable<any> } it
* @param { number } count
*/
function setLength(iter, length) {
iterLengths.set(iter, length);
return iter;
function* group(it, count) {
const it2 = iter(it);
let nextItem = it2.next();
while (!nextItem.done) {
yield [...next(it2, count, nextItem.value)];
nextItem = it2.next();
}
}

@@ -102,2 +138,3 @@ /**

* @example
* import { flat } from 'deleight/generationsl';
* for (let i of flat(range(10, range(15)))) {

@@ -107,21 +144,16 @@ * console.log(i); // 0, 0, 1, 1, 2, 2, .... till smallest iterable (10) is exhausted.

*
* @param {...Iterator<any>} args
* @param {...any[]} args
*/
function* flat(...args) {
const count = getLength(args);
const args2 = [];
let minLength;
for (let arg of args) {
if (!(arg instanceof Array))
arg = Array.from(arg);
args2.push(arg);
if (!minLength || minLength > arg.length)
minLength = arg.length;
}
let j = 0;
while (j < minLength) {
for (let i = 0; i < count; i++) {
yield args2[i][j];
const count = args.length;
args = args.map(arg => iter(arg));
let i, nextItem;
while (true) {
for (i = 0; i < count; i++) {
nextItem = args[i].next();
if (nextItem.done)
return;
else
yield nextItem.value;
}
j++;
}

@@ -133,8 +165,9 @@ }

* @example
* import { uItems } from 'deleight/generationsl';
* const unOrdered = uItems([1, 2, 3, 4]); // [4, 1, 3, 2]
*
* @param {any[]} iter
* @param {Iterable<any>} it
*/
function* uItems(iter) {
const arr = [...iter];
function* uItems(it) {
const arr = [...it];
for (let i = arr.length - 1; i >= 0; i--) {

@@ -144,3 +177,40 @@ yield arr.splice(Math.round(Math.random() * i), 1)[0];

}
/**
* Call to get the length of an object. The object must either
* have a length property of be previously passed in a call to`setLength`.
*
* @example
* import { getLength, setLength } from 'deleight/generationsl';
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
*
* @param {any} it
*/
function getLength(it) {
return iterLengths.get(it) || it.length;
}
/**
* Stores the 'fake' lenghts of iterables passed in calls to `setLength`.
* Can also be modified manually.
*/
const iterLengths = new WeakMap();
/**
* Attaches a 'fake' length to an object (likely iterable or iterator)
* which does not have a length property, so that it can work well with
* functions that use `getLength`.
*
* @example
* import { getLength, setLength } from 'deleight/generationsl';
* const myRange = range(12);
* setLength(myRange, 12);
* getLength(myRange); // returns 12.
*
* @param {any} it
*/
function setLength(it, length) {
iterLengths.set(it, length);
return it;
}
export { flat, getLength, items, iterLengths, range, repeat, setLength, uItems };
export { flat, getLength, group, items, iter, iterLengths, next, range, repeat, setLength, uItems };

@@ -21,2 +21,3 @@ /**

* @example
* import { one } from 'deleight/onetomany';
* const component = one([data(), view(table)], false, [{}]);

@@ -37,2 +38,8 @@ * component.create([10000]);

*
* @example
* import { one, unWrap } from 'deleight/onetomany';
* const o = one([{a: 1}, {a: 2}])
* o.a = [4, 7];
* const many = unWrap(o).many
*
* @param one

@@ -69,4 +76,6 @@ * @returns

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])
* o.set('a', [4, 7]);
*
*
*/

@@ -103,2 +112,3 @@ class One {

* @example
* import { One } from 'deleight/onetomany';
* const loginYes = new One([username => profileView(username)]);

@@ -121,2 +131,3 @@ * loginYes.call([[username]]);

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])

@@ -156,2 +167,3 @@ * o.get('a'); // [1, 2]

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])

@@ -182,2 +194,3 @@ * o.set('a', [4, 7]);

* @example
* import { One } from 'deleight/onetomany';
* const o = new One([{a: 1}, {a: 2}])

@@ -217,2 +230,3 @@ * o.delete('a');

* @example
* import { One } from 'deleight/onetomany';
* const loginYes = new One([username => profileView(username)]);

@@ -251,9 +265,3 @@ * loginYes.call([[username]]);

}
/**
* Pass this as the first arg in a One call to prevent it from injecting
* a context. This is an alternative to passing a third argument to the
* `call` function
*/
const ignoreContext = Symbol();
export { One, ignoreContext, one, unWrap };
export { One, one, unWrap };

@@ -29,2 +29,4 @@ /**

* @example
* import { Sophistry } from 'deleight/sophistry';
* const mySophistry = new Sophistry();
* const element = apriori.createFragment(apriori.get('markup.html'));

@@ -95,2 +97,4 @@ * const [styles, promises] = mySophistry.process(element);

* @example
* import { Sophistry } from 'deleight/sophistry';
* const mySophistry = new Sophistry();
* const [style, onImport] = mySophistry.import('style.css');

@@ -115,2 +119,4 @@ *

* @example
* import { Sophistry } from 'deleight/sophistry';
* const mySophistry = new Sophistry();
* mySophistry.set('style.css', await apriori.get('new-style.css')); // override everything.

@@ -146,3 +152,4 @@ *

* @example
* const sss = new SophistryStyleSheet(css);
* import { StyleSheet } from 'deleight/sophistry';
* const sss = new StyleSheet(css);
*

@@ -149,0 +156,0 @@ */

@@ -34,2 +34,3 @@ /**

* @example
* import { With, ASSIGN } from 'deleight/withy';
* const el = With(document.createElement('div')).append().append()[ASSIGN]().append()().append();

@@ -36,0 +37,0 @@ *

{
"name": "deleight",
"version": "1.1.3",
"version": "1.1.4",
"description": "A group of 8 libraries for writing accessible and joyfully interactive web applications with traditional HTML, CSS and JavaScript.",

@@ -69,2 +69,3 @@ "type": "module",

"Apriori",
"Eventivity",
"Sophistry",

@@ -71,0 +72,0 @@ "OneToMany",

{
"name": "deleight",
"version": "1.1.3",
"version": "1.1.4",
"description": "A group of 8 libraries for writing accessible and joyfully interactive web applications with traditional HTML, CSS and JavaScript.",

@@ -69,2 +69,3 @@ "type": "module",

"Apriori",
"Eventivity",
"Sophistry",

@@ -71,0 +72,0 @@ "OneToMany",

@@ -153,4 +153,9 @@ # Deleight

```js
import { Actribute } from "deleight/actribute";
// initialize:
const fallbackProps = { prop1: "Fallback", prop4: "Last resort" };
const fallbackProps = {
prop1: "Fallback", prop4: "Last resort",
sig: '$2b$20$o7DWuroOjbA/4LDWIstjueW9Hi6unv4fI0xAit7UQfLw/PI8iPl1y'
};
const act = new Actribute(fallbackProps);

@@ -184,3 +189,5 @@

import { With, SET } from "deleight/withy";
With(document.createElement('div'))[SET]({textContent: 'Yeah'})(div => document.body.append(div));
With(document.createElement('div'))[SET]({
textContent: 'Wow!'
})(div => document.body.append(div));
```

@@ -187,0 +194,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc