Socket
Socket
Sign inDemoInstall

deleight

Package Overview
Dependencies
Maintainers
0
Versions
61
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 4.5.0 to 4.6.0

75

dist/apption/cjs/apption.js

@@ -81,8 +81,8 @@ 'use strict';

operation = operation.value(...args);
if (operation instanceof Array)
result = act(operation, ...args);
else if (operation instanceof Action)
if (operation instanceof Action)
result = operation.act(...args);
else if (operation instanceof Function)
result = operation(...args);
else
result = operation(...args);
result = act(operation, ...args);
if (result instanceof Args)

@@ -94,2 +94,30 @@ args = result.value;

/**
* ActionMap allows us to use iterables (of key-value pairs) in place of
* objects in `call`, `set` and `del` functions (and corresponding classes).
* This can be useful for building virtual objects which are only used with
* the calls but never held fully in memory at any time, improving memory
* performance.
*
* @example
* import { call, ActionMap } from 'apption'
* let arr1 = [1, 2, 3], arr2 = [1, 2, 3], arr3 = [1, 2, 3];
* const actions = new ActionMap([[ 'push', [arr1, arr3]], ['unshift', [arr2]]]);
* call(actions, 20, 21);
* console.log(arr1) // [1, 2, 3, 20, 21]
* console.log(arr2) // [20, 21, 1, 2, 3]
* console.log(arr3) // [1, 2, 3, 20, 21]
*
*/
class ActionMap {
constructor(entries) {
this.entries = entries;
}
}
function entries(map) {
if (map instanceof ActionMap)
return map.entries;
else
return Object.entries(map);
}
/**
* Calls specified methods in multiple objects.

@@ -114,3 +142,3 @@ *

let result, object;
for (let [key, objects] of Object.entries(map)) {
for (let [key, objects] of entries(map)) {
if (objects instanceof Lazy)

@@ -156,3 +184,3 @@ objects = objects.value(key, ...args);

let object;
for (let [key, objects] of Object.entries(map)) {
for (let [key, objects] of entries(map)) {
if (objects instanceof Lazy)

@@ -188,3 +216,3 @@ objects = objects.value(key, value);

let object;
for (let [key, objects] of Object.entries(map)) {
for (let [key, objects] of entries(map)) {
if (objects instanceof Lazy)

@@ -472,2 +500,12 @@ objects = objects.value(key);

}
/**
* A more semantic alias for ArrayActions which is a light array
* wrapper containing common array modification functions.
*/
const ApptionArray = ArrayActions;
/**
* A more semantic alias for ChildrenActions which is an object
* providing a similar API to ApptionArray.
*/
const ChildrenArray = ChildrenActions;

@@ -603,3 +641,3 @@ /**

*/
const selectorTrap = {
const selectorHandler = {
get(target, p) {

@@ -682,3 +720,3 @@ return target.get(p);

if (!this.#proxy)
this.#proxy = new Proxy(this, selectorTrap);
this.#proxy = new Proxy(this, selectorHandler);
return this.#proxy;

@@ -858,7 +896,7 @@ }

if (!this.#proxy)
this.#proxy = new Proxy(this, methodSelectorTrap);
this.#proxy = new Proxy(this, methodSelectorHandler);
return this.#proxy;
}
}
const methodSelectorTrap = {
const methodSelectorHandler = {
get(target, p) {

@@ -898,3 +936,3 @@ return (...args) => target.call(p, ...args);

*/
const transformerTrap = {
const transformerHandler = {
get(transformer, p) {

@@ -955,3 +993,3 @@ return transformer.get(p);

if (!this.#proxy)
this.#proxy = new Proxy(this, transformerTrap);
this.#proxy = new Proxy(this, transformerHandler);
return this.#proxy;

@@ -979,3 +1017,3 @@ }

}
const argTrap = {
const argHandler = {
get(arg, p) {

@@ -1037,3 +1075,3 @@ return arg.get(p);

if (!this.#proxy)
this.#proxy = new Proxy(this, argTrap);
this.#proxy = new Proxy(this, argHandler);
return this.#proxy;

@@ -1064,3 +1102,3 @@ }

}
const redirectTrap = {
const redirectHandler = {
get(red, p) {

@@ -1137,3 +1175,3 @@ return red.get(p);

if (!this.#proxy)
this.#proxy = new Proxy(this, redirectTrap);
this.#proxy = new Proxy(this, redirectHandler);
return this.#proxy;

@@ -1161,2 +1199,4 @@ }

exports.Action = Action;
exports.ActionMap = ActionMap;
exports.ApptionArray = ApptionArray;
exports.Arg = Arg;

@@ -1168,2 +1208,3 @@ exports.Args = Args;

exports.ChildrenActions = ChildrenActions;
exports.ChildrenArray = ChildrenArray;
exports.DelAction = DelAction;

@@ -1170,0 +1211,0 @@ exports.Lazy = Lazy;

@@ -79,8 +79,8 @@ /**

operation = operation.value(...args);
if (operation instanceof Array)
result = act(operation, ...args);
else if (operation instanceof Action)
if (operation instanceof Action)
result = operation.act(...args);
else if (operation instanceof Function)
result = operation(...args);
else
result = operation(...args);
result = act(operation, ...args);
if (result instanceof Args)

@@ -92,2 +92,30 @@ args = result.value;

/**
* ActionMap allows us to use iterables (of key-value pairs) in place of
* objects in `call`, `set` and `del` functions (and corresponding classes).
* This can be useful for building virtual objects which are only used with
* the calls but never held fully in memory at any time, improving memory
* performance.
*
* @example
* import { call, ActionMap } from 'apption'
* let arr1 = [1, 2, 3], arr2 = [1, 2, 3], arr3 = [1, 2, 3];
* const actions = new ActionMap([[ 'push', [arr1, arr3]], ['unshift', [arr2]]]);
* call(actions, 20, 21);
* console.log(arr1) // [1, 2, 3, 20, 21]
* console.log(arr2) // [20, 21, 1, 2, 3]
* console.log(arr3) // [1, 2, 3, 20, 21]
*
*/
class ActionMap {
constructor(entries) {
this.entries = entries;
}
}
function entries(map) {
if (map instanceof ActionMap)
return map.entries;
else
return Object.entries(map);
}
/**
* Calls specified methods in multiple objects.

@@ -112,3 +140,3 @@ *

let result, object;
for (let [key, objects] of Object.entries(map)) {
for (let [key, objects] of entries(map)) {
if (objects instanceof Lazy)

@@ -154,3 +182,3 @@ objects = objects.value(key, ...args);

let object;
for (let [key, objects] of Object.entries(map)) {
for (let [key, objects] of entries(map)) {
if (objects instanceof Lazy)

@@ -186,3 +214,3 @@ objects = objects.value(key, value);

let object;
for (let [key, objects] of Object.entries(map)) {
for (let [key, objects] of entries(map)) {
if (objects instanceof Lazy)

@@ -470,2 +498,12 @@ objects = objects.value(key);

}
/**
* A more semantic alias for ArrayActions which is a light array
* wrapper containing common array modification functions.
*/
const ApptionArray = ArrayActions;
/**
* A more semantic alias for ChildrenActions which is an object
* providing a similar API to ApptionArray.
*/
const ChildrenArray = ChildrenActions;

@@ -601,3 +639,3 @@ /**

*/
const selectorTrap = {
const selectorHandler = {
get(target, p) {

@@ -680,3 +718,3 @@ return target.get(p);

if (!this.#proxy)
this.#proxy = new Proxy(this, selectorTrap);
this.#proxy = new Proxy(this, selectorHandler);
return this.#proxy;

@@ -856,7 +894,7 @@ }

if (!this.#proxy)
this.#proxy = new Proxy(this, methodSelectorTrap);
this.#proxy = new Proxy(this, methodSelectorHandler);
return this.#proxy;
}
}
const methodSelectorTrap = {
const methodSelectorHandler = {
get(target, p) {

@@ -896,3 +934,3 @@ return (...args) => target.call(p, ...args);

*/
const transformerTrap = {
const transformerHandler = {
get(transformer, p) {

@@ -953,3 +991,3 @@ return transformer.get(p);

if (!this.#proxy)
this.#proxy = new Proxy(this, transformerTrap);
this.#proxy = new Proxy(this, transformerHandler);
return this.#proxy;

@@ -977,3 +1015,3 @@ }

}
const argTrap = {
const argHandler = {
get(arg, p) {

@@ -1035,3 +1073,3 @@ return arg.get(p);

if (!this.#proxy)
this.#proxy = new Proxy(this, argTrap);
this.#proxy = new Proxy(this, argHandler);
return this.#proxy;

@@ -1062,3 +1100,3 @@ }

}
const redirectTrap = {
const redirectHandler = {
get(red, p) {

@@ -1135,3 +1173,3 @@ return red.get(p);

if (!this.#proxy)
this.#proxy = new Proxy(this, redirectTrap);
this.#proxy = new Proxy(this, redirectHandler);
return this.#proxy;

@@ -1158,2 +1196,2 @@ }

export { Action, Arg, Args, ArrayActions, AttrSelector, CallAction, ChildrenActions, DelAction, Lazy, MemberSelector, MethodSelector, ObjectAction, Redirect, Selector, SetAction, Transformer, act, arg, attr, call, del, foreach, map, mapKeys, mapValues, member, method, redirect, reduce, selector, set, transformer, zip };
export { Action, ActionMap, ApptionArray, Arg, Args, ArrayActions, AttrSelector, CallAction, ChildrenActions, ChildrenArray, DelAction, Lazy, MemberSelector, MethodSelector, ObjectAction, Redirect, Selector, SetAction, Transformer, act, arg, attr, call, del, foreach, map, mapKeys, mapValues, member, method, redirect, reduce, selector, set, transformer, zip };
/**
* This module exports primitives for building DOM from text.
* This module exports primitives for building and/or setting up DOM in various ways.
*

@@ -151,2 +151,40 @@ * @module

/**
* Sets up the specified element(s) with the given arguments.
*
* The values in `args` are interpreted as follows:
* 1. string, number and Node values are appended to the element
* 2. functions values are called with the element as the sole argument
* 3. object values are used to assign properties using `Object.assign`
*
* This function is also used internally to set up new elements created with
* {@link e}.
*
* Note that because of how Node appends work, any nodes `args` will end up
* appended only to the last element in `elements` (if they are more than one).
* Conversely, any fragments in `args` will have their nodes only
* appended to the first element in `elements`.
*
* @example
* import { setup, e } from 'deleight/apriori';
* const tree = document.querySelector('main');
* setup(
* main,
* e.h1('Title',
* h1 => console.log(h1, ' created')
* ),
* e.section(
* e.h2('Section 1'),
* e.p(
* 'This is the first section',
* { className: 'text-centre' }
* )
* )
* );
*
* @param elements the element(s) to setup
* @param args the setup arguments
* @returns this same function to support chaining multiple setup calls.
*/
declare function setup(elements: Element | Iterable<Element>, ...args: any[]): typeof setup;
/**
* A simple proxy object for creating and 'setting up' a new element in one go.

@@ -198,2 +236,2 @@ * Can be nested to create and setup entire DOM trees. This is much more

export { type IAsyncTemplates, type ITemplates, asyncTemplate, asyncTemplates, createFragment, e, elements, escObject, escString, get, tag, template, templates };
export { type IAsyncTemplates, type ITemplates, asyncTemplate, asyncTemplates, createFragment, e, elements, escObject, escString, get, setup, tag, template, templates };
'use strict';
/**
* This module exports primitives for building DOM from text.
* This module exports primitives for building and/or setting up DOM in various ways.
*

@@ -212,16 +212,63 @@ * @module

}
const eTrap = {
/**
* Sets up the specified element(s) with the given arguments.
*
* The values in `args` are interpreted as follows:
* 1. string, number and Node values are appended to the element
* 2. functions values are called with the element as the sole argument
* 3. object values are used to assign properties using `Object.assign`
*
* This function is also used internally to set up new elements created with
* {@link e}.
*
* Note that because of how Node appends work, any nodes `args` will end up
* appended only to the last element in `elements` (if they are more than one).
* Conversely, any fragments in `args` will have their nodes only
* appended to the first element in `elements`.
*
* @example
* import { setup, e } from 'deleight/apriori';
* const tree = document.querySelector('main');
* setup(
* main,
* e.h1('Title',
* h1 => console.log(h1, ' created')
* ),
* e.section(
* e.h2('Section 1'),
* e.p(
* 'This is the first section',
* { className: 'text-centre' }
* )
* )
* );
*
* @param elements the element(s) to setup
* @param args the setup arguments
* @returns this same function to support chaining multiple setup calls.
*/
function setup(elements, ...args) {
if (elements instanceof Element)
elements = [elements];
for (let element of elements) {
for (let arg of args) {
if (typeof arg === 'number')
arg = `${arg}`;
if (arg instanceof Node)
element.appendChild(arg); // append node
else if (typeof arg === 'string')
element.append(arg); // append text node
else if (arg instanceof Function)
arg(element); // arbitrary setup
else if (typeof arg === 'object')
Object.assign(element, arg); // set properties
}
}
return setup;
}
const eHandler = {
get(target, p) {
const element = document.createElement(p);
return (...args) => {
for (let arg of args) {
if (arg instanceof Node)
element.appendChild(arg); // append node
else if (typeof arg === 'string')
element.append(arg); // append text node
else if (arg instanceof Function)
arg(element); // arbitrary setup
else if (typeof arg === 'object')
Object.assign(element, arg); // set properties
}
setup(element, ...args);
return element;

@@ -250,3 +297,3 @@ };

*/
const e = new Proxy({}, eTrap);
const e = new Proxy(setup, eHandler);
/**

@@ -310,4 +357,5 @@ * Returns an object which escapes properties sourced from it. Escaping markup is a key component of template rendering,

exports.get = get;
exports.setup = setup;
exports.tag = tag;
exports.template = template;
exports.templates = templates;
/**
* This module exports primitives for building DOM from text.
* This module exports primitives for building and/or setting up DOM in various ways.
*

@@ -151,2 +151,40 @@ * @module

/**
* Sets up the specified element(s) with the given arguments.
*
* The values in `args` are interpreted as follows:
* 1. string, number and Node values are appended to the element
* 2. functions values are called with the element as the sole argument
* 3. object values are used to assign properties using `Object.assign`
*
* This function is also used internally to set up new elements created with
* {@link e}.
*
* Note that because of how Node appends work, any nodes `args` will end up
* appended only to the last element in `elements` (if they are more than one).
* Conversely, any fragments in `args` will have their nodes only
* appended to the first element in `elements`.
*
* @example
* import { setup, e } from 'deleight/apriori';
* const tree = document.querySelector('main');
* setup(
* main,
* e.h1('Title',
* h1 => console.log(h1, ' created')
* ),
* e.section(
* e.h2('Section 1'),
* e.p(
* 'This is the first section',
* { className: 'text-centre' }
* )
* )
* );
*
* @param elements the element(s) to setup
* @param args the setup arguments
* @returns this same function to support chaining multiple setup calls.
*/
declare function setup(elements: Element | Iterable<Element>, ...args: any[]): typeof setup;
/**
* A simple proxy object for creating and 'setting up' a new element in one go.

@@ -198,2 +236,2 @@ * Can be nested to create and setup entire DOM trees. This is much more

export { type IAsyncTemplates, type ITemplates, asyncTemplate, asyncTemplates, createFragment, e, elements, escObject, escString, get, tag, template, templates };
export { type IAsyncTemplates, type ITemplates, asyncTemplate, asyncTemplates, createFragment, e, elements, escObject, escString, get, setup, tag, template, templates };
/**
* This module exports primitives for building DOM from text.
* This module exports primitives for building and/or setting up DOM in various ways.
*

@@ -210,16 +210,63 @@ * @module

}
const eTrap = {
/**
* Sets up the specified element(s) with the given arguments.
*
* The values in `args` are interpreted as follows:
* 1. string, number and Node values are appended to the element
* 2. functions values are called with the element as the sole argument
* 3. object values are used to assign properties using `Object.assign`
*
* This function is also used internally to set up new elements created with
* {@link e}.
*
* Note that because of how Node appends work, any nodes `args` will end up
* appended only to the last element in `elements` (if they are more than one).
* Conversely, any fragments in `args` will have their nodes only
* appended to the first element in `elements`.
*
* @example
* import { setup, e } from 'deleight/apriori';
* const tree = document.querySelector('main');
* setup(
* main,
* e.h1('Title',
* h1 => console.log(h1, ' created')
* ),
* e.section(
* e.h2('Section 1'),
* e.p(
* 'This is the first section',
* { className: 'text-centre' }
* )
* )
* );
*
* @param elements the element(s) to setup
* @param args the setup arguments
* @returns this same function to support chaining multiple setup calls.
*/
function setup(elements, ...args) {
if (elements instanceof Element)
elements = [elements];
for (let element of elements) {
for (let arg of args) {
if (typeof arg === 'number')
arg = `${arg}`;
if (arg instanceof Node)
element.appendChild(arg); // append node
else if (typeof arg === 'string')
element.append(arg); // append text node
else if (arg instanceof Function)
arg(element); // arbitrary setup
else if (typeof arg === 'object')
Object.assign(element, arg); // set properties
}
}
return setup;
}
const eHandler = {
get(target, p) {
const element = document.createElement(p);
return (...args) => {
for (let arg of args) {
if (arg instanceof Node)
element.appendChild(arg); // append node
else if (typeof arg === 'string')
element.append(arg); // append text node
else if (arg instanceof Function)
arg(element); // arbitrary setup
else if (typeof arg === 'object')
Object.assign(element, arg); // set properties
}
setup(element, ...args);
return element;

@@ -248,3 +295,3 @@ };

*/
const e = new Proxy({}, eTrap);
const e = new Proxy(setup, eHandler);
/**

@@ -300,2 +347,2 @@ * Returns an object which escapes properties sourced from it. Escaping markup is a key component of template rendering,

export { asyncTemplate, asyncTemplates, createFragment, e, elements, escObject, escString, get, tag, template, templates };
export { asyncTemplate, asyncTemplates, createFragment, e, elements, escObject, escString, get, setup, tag, template, templates };

@@ -53,7 +53,7 @@ 'use strict';

}, { obj });
const proxy = new Proxy(target, trap);
const proxy = new Proxy(target, handler);
target.proxy = proxy;
return proxy;
}
const trap = {
const handler = {
get(target, p) {

@@ -60,0 +60,0 @@ if (p === ASSIGN) {

@@ -51,7 +51,7 @@ /**

}, { obj });
const proxy = new Proxy(target, trap);
const proxy = new Proxy(target, handler);
target.proxy = proxy;
return proxy;
}
const trap = {
const handler = {
get(target, p) {

@@ -58,0 +58,0 @@ if (p === ASSIGN) {

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

@@ -64,5 +64,8 @@ "type": "module",

"keywords": [
"frontend",
"HTML",
"CSS",
"JavaScript",
"library",
"framework",
"vanilla",

@@ -73,2 +76,3 @@ "reactivity",

"Deleight",
"Apption",
"Actribute",

@@ -75,0 +79,0 @@ "Appliance",

@@ -29,3 +29,3 @@ # Deleight

Apption is a simple and pragmatic library for composing clean, efficient and succinct frontend applications. It exports several primitives for performing common actions in a typical web application. Further details can be found within its repository at https://github.com/mksunny1/apption. It consolidates some of the most useful patterns from developing and using earlier libraries and from writing a lot of JavaScript code.
Apption is a simple and pragmatic library for composing clean, efficient and succinct frontend applications. It exports several primitives for performing common actions in a typical web application. Further details can be found within its package at https://www.npmjs.com/package/apption. It consolidates some of the most useful patterns from developing and using earlier libraries and from writing a lot of JavaScript code.

@@ -32,0 +32,0 @@ ```js

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