defuss-runtime 1.0.3 → 1.1.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/README.md CHANGED
@@ -211,6 +211,6 @@ All commands are run from the root of the project, from a terminal:
211
211
 
212
212
  ---
213
213
 
214
- <img src="assets/defuss_comic.png" />
214
+ <img src="https://raw.githubusercontent.com/kyr0/defuss/refs/heads/main/assets/defuss_comic.png" />
215
215
 
216
216
  <caption><i><b>Come visit us on defuss island!</b></i></caption>
package/dist/index.cjs CHANGED
@@ -387,6 +387,22 @@ const asInteger = (value) => {
387
387
  return asNumber(Number.parseInt(asString(number), 10).toFixed(0));
388
388
  };
389
389
 
390
+ const isTrue = (value) => {
391
+ return value === true;
392
+ };
393
+
394
+ const isFalse = (value) => {
395
+ return value === false;
396
+ };
397
+
398
+ const isTruthy = (value) => {
399
+ return !!value;
400
+ };
401
+
402
+ const isFalsy = (value) => {
403
+ return !value;
404
+ };
405
+
390
406
  const isAfter = (value, minDate, inclusive = false) => {
391
407
  return value instanceof Date && (inclusive ? value.getTime() >= minDate.getTime() : value.getTime() > minDate.getTime());
392
408
  };
@@ -487,6 +503,17 @@ const isInteger = (value) => isSafeNumber(value) && Number.isInteger(value);
487
503
 
488
504
  const isEqual = (value, valueB) => equalsJSON(value, valueB);
489
505
 
506
+ function preload(url, as = "image") {
507
+ const urls = Array.isArray(url) ? url : [url];
508
+ urls.forEach((u) => {
509
+ const p = document.createElement("link");
510
+ p.href = u;
511
+ p.rel = "preload";
512
+ p.as = as;
513
+ document.head.appendChild(p);
514
+ });
515
+ }
516
+
490
517
  exports.PATH_ACCESSOR_SYMBOL = PATH_ACCESSOR_SYMBOL;
491
518
  exports._BASE64_CHARS = _BASE64_CHARS;
492
519
  exports._HEX_PREFIX = _HEX_PREFIX;
@@ -521,6 +548,8 @@ exports.isDefined = isDefined;
521
548
  exports.isEmail = isEmail;
522
549
  exports.isEmpty = isEmpty;
523
550
  exports.isEqual = isEqual;
551
+ exports.isFalse = isFalse;
552
+ exports.isFalsy = isFalsy;
524
553
  exports.isGreaterThan = isGreaterThan;
525
554
  exports.isInteger = isInteger;
526
555
  exports.isLessThan = isLessThan;
@@ -535,10 +564,13 @@ exports.isSafeNumeric = isSafeNumeric;
535
564
  exports.isShorterThan = isShorterThan;
536
565
  exports.isSlug = isSlug;
537
566
  exports.isString = isString;
567
+ exports.isTrue = isTrue;
568
+ exports.isTruthy = isTruthy;
538
569
  exports.isUrl = isUrl;
539
570
  exports.isUrlPath = isUrlPath;
540
571
  exports.omit = omit;
541
572
  exports.pick = pick;
573
+ exports.preload = preload;
542
574
  exports.setByPath = setByPath;
543
575
  exports.textToBinary = textToBinary;
544
576
  exports.throttle = throttle;
package/dist/index.d.cts CHANGED
@@ -149,6 +149,28 @@ declare const asDate: (value: any) => Date;
149
149
 
150
150
  declare const asInteger: (value: any) => number;
151
151
 
152
+ /**
153
+ * Transformer that checks if a value is strictly true.
154
+ */
155
+ declare const isTrue: (value: any) => boolean;
156
+
157
+ /**
158
+ * Transformer that checks if a value is strictly false.
159
+ */
160
+ declare const isFalse: (value: any) => boolean;
161
+
162
+ /**
163
+ * Transformer that checks if a value is truthy.
164
+ * Returns true for all truthy values (non-zero numbers, non-empty strings, objects, etc.)
165
+ */
166
+ declare const isTruthy: (value: any) => boolean;
167
+
168
+ /**
169
+ * Transformer that checks if a value is falsy.
170
+ * Returns true for all falsy values (false, 0, "", null, undefined, NaN)
171
+ */
172
+ declare const isFalsy: (value: any) => boolean;
173
+
152
174
  declare const isAfter: (value: Date | undefined, minDate: Date, inclusive?: boolean) => value is Date;
153
175
 
154
176
  type ValidationMessage = string | number | boolean | null | undefined;
@@ -235,4 +257,7 @@ declare const isInteger: ValidatorPrimitiveFn;
235
257
 
236
258
  declare const isEqual: (value: any, valueB: any) => boolean;
237
259
 
238
- export { type DateValue, type Dynamic, PATH_ACCESSOR_SYMBOL, type PathAccessor, type SingleValidationResult, type ValidationFnResult, type ValidationMessage, type ValidationStep, type ValidatorFn, type ValidatorPrimitiveFn, _BASE64_CHARS, _HEX_PREFIX, _base64LookupMap, _getBase64LookupMap, access, asArray, asBoolean, asDate, asInteger, asNumber, asString, base64ToBinary, binaryToBase64, binaryToHex, binaryToText, createTimeoutPromise, debounce, ensureKey, equalsJSON, getAllKeysFromPath, getByPath, getDateValue, hasPattern, hexToBinary, is, isAfter, isArray, isBefore, isBoolean, isDate, isDefined, isEmail, isEmpty, isEqual, isGreaterThan, isInteger, isLessThan, isLongerThan, isObject, isOneOf, isPathAccessor, isPhoneNumber, isRequired, isSafeNumber, isSafeNumeric, isShorterThan, isSlug, isString, isUrl, isUrlPath, omit, pick, setByPath, textToBinary, throttle, unique, wait, waitForRef, waitForWithPolling };
260
+ type PreloadAs = "image" | "script" | "style" | "fetch" | "track" | "font";
261
+ declare function preload(url: string | string[], as?: PreloadAs): void;
262
+
263
+ export { type DateValue, type Dynamic, PATH_ACCESSOR_SYMBOL, type PathAccessor, type PreloadAs, type SingleValidationResult, type ValidationFnResult, type ValidationMessage, type ValidationStep, type ValidatorFn, type ValidatorPrimitiveFn, _BASE64_CHARS, _HEX_PREFIX, _base64LookupMap, _getBase64LookupMap, access, asArray, asBoolean, asDate, asInteger, asNumber, asString, base64ToBinary, binaryToBase64, binaryToHex, binaryToText, createTimeoutPromise, debounce, ensureKey, equalsJSON, getAllKeysFromPath, getByPath, getDateValue, hasPattern, hexToBinary, is, isAfter, isArray, isBefore, isBoolean, isDate, isDefined, isEmail, isEmpty, isEqual, isFalse, isFalsy, isGreaterThan, isInteger, isLessThan, isLongerThan, isObject, isOneOf, isPathAccessor, isPhoneNumber, isRequired, isSafeNumber, isSafeNumeric, isShorterThan, isSlug, isString, isTrue, isTruthy, isUrl, isUrlPath, omit, pick, preload, setByPath, textToBinary, throttle, unique, wait, waitForRef, waitForWithPolling };
package/dist/index.d.mts CHANGED
@@ -149,6 +149,28 @@ declare const asDate: (value: any) => Date;
149
149
 
150
150
  declare const asInteger: (value: any) => number;
151
151
 
152
+ /**
153
+ * Transformer that checks if a value is strictly true.
154
+ */
155
+ declare const isTrue: (value: any) => boolean;
156
+
157
+ /**
158
+ * Transformer that checks if a value is strictly false.
159
+ */
160
+ declare const isFalse: (value: any) => boolean;
161
+
162
+ /**
163
+ * Transformer that checks if a value is truthy.
164
+ * Returns true for all truthy values (non-zero numbers, non-empty strings, objects, etc.)
165
+ */
166
+ declare const isTruthy: (value: any) => boolean;
167
+
168
+ /**
169
+ * Transformer that checks if a value is falsy.
170
+ * Returns true for all falsy values (false, 0, "", null, undefined, NaN)
171
+ */
172
+ declare const isFalsy: (value: any) => boolean;
173
+
152
174
  declare const isAfter: (value: Date | undefined, minDate: Date, inclusive?: boolean) => value is Date;
153
175
 
154
176
  type ValidationMessage = string | number | boolean | null | undefined;
@@ -235,4 +257,7 @@ declare const isInteger: ValidatorPrimitiveFn;
235
257
 
236
258
  declare const isEqual: (value: any, valueB: any) => boolean;
237
259
 
238
- export { type DateValue, type Dynamic, PATH_ACCESSOR_SYMBOL, type PathAccessor, type SingleValidationResult, type ValidationFnResult, type ValidationMessage, type ValidationStep, type ValidatorFn, type ValidatorPrimitiveFn, _BASE64_CHARS, _HEX_PREFIX, _base64LookupMap, _getBase64LookupMap, access, asArray, asBoolean, asDate, asInteger, asNumber, asString, base64ToBinary, binaryToBase64, binaryToHex, binaryToText, createTimeoutPromise, debounce, ensureKey, equalsJSON, getAllKeysFromPath, getByPath, getDateValue, hasPattern, hexToBinary, is, isAfter, isArray, isBefore, isBoolean, isDate, isDefined, isEmail, isEmpty, isEqual, isGreaterThan, isInteger, isLessThan, isLongerThan, isObject, isOneOf, isPathAccessor, isPhoneNumber, isRequired, isSafeNumber, isSafeNumeric, isShorterThan, isSlug, isString, isUrl, isUrlPath, omit, pick, setByPath, textToBinary, throttle, unique, wait, waitForRef, waitForWithPolling };
260
+ type PreloadAs = "image" | "script" | "style" | "fetch" | "track" | "font";
261
+ declare function preload(url: string | string[], as?: PreloadAs): void;
262
+
263
+ export { type DateValue, type Dynamic, PATH_ACCESSOR_SYMBOL, type PathAccessor, type PreloadAs, type SingleValidationResult, type ValidationFnResult, type ValidationMessage, type ValidationStep, type ValidatorFn, type ValidatorPrimitiveFn, _BASE64_CHARS, _HEX_PREFIX, _base64LookupMap, _getBase64LookupMap, access, asArray, asBoolean, asDate, asInteger, asNumber, asString, base64ToBinary, binaryToBase64, binaryToHex, binaryToText, createTimeoutPromise, debounce, ensureKey, equalsJSON, getAllKeysFromPath, getByPath, getDateValue, hasPattern, hexToBinary, is, isAfter, isArray, isBefore, isBoolean, isDate, isDefined, isEmail, isEmpty, isEqual, isFalse, isFalsy, isGreaterThan, isInteger, isLessThan, isLongerThan, isObject, isOneOf, isPathAccessor, isPhoneNumber, isRequired, isSafeNumber, isSafeNumeric, isShorterThan, isSlug, isString, isTrue, isTruthy, isUrl, isUrlPath, omit, pick, preload, setByPath, textToBinary, throttle, unique, wait, waitForRef, waitForWithPolling };
package/dist/index.mjs CHANGED
@@ -385,6 +385,22 @@ const asInteger = (value) => {
385
385
  return asNumber(Number.parseInt(asString(number), 10).toFixed(0));
386
386
  };
387
387
 
388
+ const isTrue = (value) => {
389
+ return value === true;
390
+ };
391
+
392
+ const isFalse = (value) => {
393
+ return value === false;
394
+ };
395
+
396
+ const isTruthy = (value) => {
397
+ return !!value;
398
+ };
399
+
400
+ const isFalsy = (value) => {
401
+ return !value;
402
+ };
403
+
388
404
  const isAfter = (value, minDate, inclusive = false) => {
389
405
  return value instanceof Date && (inclusive ? value.getTime() >= minDate.getTime() : value.getTime() > minDate.getTime());
390
406
  };
@@ -485,4 +501,15 @@ const isInteger = (value) => isSafeNumber(value) && Number.isInteger(value);
485
501
 
486
502
  const isEqual = (value, valueB) => equalsJSON(value, valueB);
487
503
 
488
- export { PATH_ACCESSOR_SYMBOL, _BASE64_CHARS, _HEX_PREFIX, _base64LookupMap, _getBase64LookupMap, access, asArray, asBoolean, asDate, asInteger, asNumber, asString, base64ToBinary, binaryToBase64, binaryToHex, binaryToText, createTimeoutPromise, debounce, ensureKey, equalsJSON, getAllKeysFromPath, getByPath, getDateValue, hasPattern, hexToBinary, is, isAfter, isArray, isBefore, isBoolean, isDate, isDefined, isEmail, isEmpty, isEqual, isGreaterThan, isInteger, isLessThan, isLongerThan, isObject, isOneOf, isPathAccessor, isPhoneNumber, isRequired, isSafeNumber, isSafeNumeric, isShorterThan, isSlug, isString, isUrl, isUrlPath, omit, pick, setByPath, textToBinary, throttle, unique, wait, waitForRef, waitForWithPolling };
504
+ function preload(url, as = "image") {
505
+ const urls = Array.isArray(url) ? url : [url];
506
+ urls.forEach((u) => {
507
+ const p = document.createElement("link");
508
+ p.href = u;
509
+ p.rel = "preload";
510
+ p.as = as;
511
+ document.head.appendChild(p);
512
+ });
513
+ }
514
+
515
+ export { PATH_ACCESSOR_SYMBOL, _BASE64_CHARS, _HEX_PREFIX, _base64LookupMap, _getBase64LookupMap, access, asArray, asBoolean, asDate, asInteger, asNumber, asString, base64ToBinary, binaryToBase64, binaryToHex, binaryToText, createTimeoutPromise, debounce, ensureKey, equalsJSON, getAllKeysFromPath, getByPath, getDateValue, hasPattern, hexToBinary, is, isAfter, isArray, isBefore, isBoolean, isDate, isDefined, isEmail, isEmpty, isEqual, isFalse, isFalsy, isGreaterThan, isInteger, isLessThan, isLongerThan, isObject, isOneOf, isPathAccessor, isPhoneNumber, isRequired, isSafeNumber, isSafeNumeric, isShorterThan, isSlug, isString, isTrue, isTruthy, isUrl, isUrlPath, omit, pick, preload, setByPath, textToBinary, throttle, unique, wait, waitForRef, waitForWithPolling };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "defuss-runtime",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"