@oscarpalmer/toretto 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +0 -157
- package/package.json +2 -2
- package/src/data.ts +1 -1
- package/src/find/index.ts +1 -1
- package/src/internal/attribute.ts +1 -1
package/dist/data.d.mts
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -187,7 +187,7 @@ declare function isInvalidBooleanAttribute(attribute: Attr | Attribute): boolean
|
|
|
187
187
|
*/
|
|
188
188
|
declare function isInvalidBooleanAttribute(name: string, value: string): boolean;
|
|
189
189
|
//#endregion
|
|
190
|
-
//#region node_modules/@oscarpalmer/atoms/dist/
|
|
190
|
+
//#region node_modules/@oscarpalmer/atoms/dist/models.d.mts
|
|
191
191
|
/**
|
|
192
192
|
* A generic object
|
|
193
193
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -653,163 +653,6 @@ const ATTRIBUTE_DATA_PREFIX = "data-";
|
|
|
653
653
|
*/
|
|
654
654
|
function noop() {}
|
|
655
655
|
//#endregion
|
|
656
|
-
//#region node_modules/@oscarpalmer/atoms/dist/function/assert.mjs
|
|
657
|
-
/**
|
|
658
|
-
* Asserts that a condition is true, throwing an error if it is not
|
|
659
|
-
* @param condition Condition to assert
|
|
660
|
-
* @param message Error message
|
|
661
|
-
* @param error Error constructor
|
|
662
|
-
*/
|
|
663
|
-
function assert(condition, message, error) {
|
|
664
|
-
if (!condition()) throw new (error ?? Error)(message);
|
|
665
|
-
}
|
|
666
|
-
assert.condition = assertCondition;
|
|
667
|
-
assert.defined = assertDefined;
|
|
668
|
-
assert.instanceOf = assertInstanceOf;
|
|
669
|
-
assert.is = assertIs;
|
|
670
|
-
/**
|
|
671
|
-
* Creates an asserter that asserts a condition is true, throwing an error if it is not
|
|
672
|
-
* @param condition Condition to assert
|
|
673
|
-
* @param message Error message
|
|
674
|
-
* @param error Error constructor
|
|
675
|
-
* @returns Asserter
|
|
676
|
-
*/
|
|
677
|
-
function assertCondition(condition, message, error) {
|
|
678
|
-
return (value) => {
|
|
679
|
-
assert(() => condition(value), message, error);
|
|
680
|
-
};
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Asserts that a value is defined throwing an error if it is not
|
|
684
|
-
* @param value Value to assert
|
|
685
|
-
* @param message Error message
|
|
686
|
-
*/
|
|
687
|
-
function assertDefined(value, message) {
|
|
688
|
-
assert(() => value != null, message ?? MESSAGE_VALUE_DEFINED);
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* Creates an asserter that asserts a value is an instance of a constructor, throwing an error if it is not
|
|
692
|
-
* @param constructor Constructor to check against
|
|
693
|
-
* @param message Error message
|
|
694
|
-
* @param error Error constructor
|
|
695
|
-
* @returns Asserter
|
|
696
|
-
*/
|
|
697
|
-
function assertInstanceOf(constructor, message, error) {
|
|
698
|
-
return (value) => {
|
|
699
|
-
assert(() => value instanceof constructor, message, error);
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
/**
|
|
703
|
-
* Creates an asserter that asserts a value is of a specific type, throwing an error if it is not
|
|
704
|
-
* @param condition Type guard function to check the value
|
|
705
|
-
* @param message Error message
|
|
706
|
-
* @param error Error constructor
|
|
707
|
-
* @returns Asserter
|
|
708
|
-
*/
|
|
709
|
-
function assertIs(condition, message, error) {
|
|
710
|
-
return (value) => {
|
|
711
|
-
assert(() => condition(value), message, error);
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
const MESSAGE_VALUE_DEFINED = "Expected value to be defined";
|
|
715
|
-
//#endregion
|
|
716
|
-
//#region node_modules/@oscarpalmer/atoms/dist/function/once.mjs
|
|
717
|
-
/**
|
|
718
|
-
* Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
|
|
719
|
-
* @param callback Callback to use once
|
|
720
|
-
* @returns Once callback
|
|
721
|
-
*/
|
|
722
|
-
function asyncOnce(callback) {
|
|
723
|
-
assert(() => typeof callback === "function", MESSAGE_EXPECTATION);
|
|
724
|
-
const state = {
|
|
725
|
-
called: false,
|
|
726
|
-
cleared: false,
|
|
727
|
-
error: false,
|
|
728
|
-
finished: false,
|
|
729
|
-
items: [],
|
|
730
|
-
value: void 0
|
|
731
|
-
};
|
|
732
|
-
const fn = (...parameters) => {
|
|
733
|
-
if (state.cleared) return Promise.reject(new Error(MESSAGE_CLEARED));
|
|
734
|
-
if (state.finished) return state.error ? Promise.reject(state.value) : Promise.resolve(state.value);
|
|
735
|
-
if (state.called) return new Promise((resolve, reject) => {
|
|
736
|
-
state.items.push({
|
|
737
|
-
reject,
|
|
738
|
-
resolve
|
|
739
|
-
});
|
|
740
|
-
});
|
|
741
|
-
state.called = true;
|
|
742
|
-
return new Promise((resolve, reject) => {
|
|
743
|
-
state.items.push({
|
|
744
|
-
reject,
|
|
745
|
-
resolve
|
|
746
|
-
});
|
|
747
|
-
callback(...parameters).then((value) => {
|
|
748
|
-
handleResult(state, value, false);
|
|
749
|
-
}).catch((error) => {
|
|
750
|
-
handleResult(state, error, true);
|
|
751
|
-
});
|
|
752
|
-
});
|
|
753
|
-
};
|
|
754
|
-
Object.defineProperties(fn, {
|
|
755
|
-
called: { get: () => state.called },
|
|
756
|
-
cleared: { get: () => state.cleared },
|
|
757
|
-
error: { get: () => state.error },
|
|
758
|
-
finished: { get: () => state.finished }
|
|
759
|
-
});
|
|
760
|
-
fn.clear = () => {
|
|
761
|
-
if (!state.called || !state.finished || state.cleared) return;
|
|
762
|
-
state.cleared = true;
|
|
763
|
-
state.value = void 0;
|
|
764
|
-
};
|
|
765
|
-
return fn;
|
|
766
|
-
}
|
|
767
|
-
function handleResult(state, value, error) {
|
|
768
|
-
state.error = error;
|
|
769
|
-
state.finished = true;
|
|
770
|
-
state.value = value;
|
|
771
|
-
const items = state.items.splice(0);
|
|
772
|
-
const { length } = items;
|
|
773
|
-
for (let index = 0; index < length; index += 1) {
|
|
774
|
-
const { reject, resolve } = items[index];
|
|
775
|
-
if (error) reject(value);
|
|
776
|
-
else resolve(value);
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
/**
|
|
780
|
-
* Create a function that can only be called once, returning the same value on subsequent calls
|
|
781
|
-
* @param callback Callback to use once
|
|
782
|
-
* @returns Once callback
|
|
783
|
-
*/
|
|
784
|
-
function once(callback) {
|
|
785
|
-
assert(() => typeof callback === "function", MESSAGE_EXPECTATION);
|
|
786
|
-
const state = {
|
|
787
|
-
called: false,
|
|
788
|
-
cleared: false,
|
|
789
|
-
value: void 0
|
|
790
|
-
};
|
|
791
|
-
const fn = (...parameters) => {
|
|
792
|
-
if (state.cleared) throw new Error(MESSAGE_CLEARED);
|
|
793
|
-
if (state.called) return state.value;
|
|
794
|
-
state.called = true;
|
|
795
|
-
state.value = callback(...parameters);
|
|
796
|
-
return state.value;
|
|
797
|
-
};
|
|
798
|
-
Object.defineProperties(fn, {
|
|
799
|
-
called: { get: () => state.called },
|
|
800
|
-
cleared: { get: () => state.cleared }
|
|
801
|
-
});
|
|
802
|
-
fn.clear = () => {
|
|
803
|
-
if (!state.called || state.cleared) return;
|
|
804
|
-
state.cleared = true;
|
|
805
|
-
state.value = void 0;
|
|
806
|
-
};
|
|
807
|
-
return fn;
|
|
808
|
-
}
|
|
809
|
-
once.async = asyncOnce;
|
|
810
|
-
const MESSAGE_CLEARED = "Once has been cleared";
|
|
811
|
-
const MESSAGE_EXPECTATION = "Once expected a function";
|
|
812
|
-
//#endregion
|
|
813
656
|
//#region src/event/delegation.ts
|
|
814
657
|
function addDelegatedHandler(doc, type, name, passive) {
|
|
815
658
|
if (DELEGATED.has(name)) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oscarpalmer/toretto",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "A collection of badass DOM utilities.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dom",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"watch": "npx vite build --watch"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@oscarpalmer/atoms": "^0.
|
|
82
|
+
"@oscarpalmer/atoms": "^0.165"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/node": "^25.5",
|
package/src/data.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {PlainObject} from '@oscarpalmer/atoms';
|
|
1
|
+
import type {PlainObject} from '@oscarpalmer/atoms/models';
|
|
2
2
|
import {parse} from '@oscarpalmer/atoms/string';
|
|
3
3
|
import {kebabCase} from '@oscarpalmer/atoms/string/case';
|
|
4
4
|
import {setElementValues, updateElementValue} from './internal/element-value';
|
package/src/find/index.ts
CHANGED