yummies 7.19.3 → 7.20.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.
Files changed (162) hide show
  1. package/assert.cjs +1 -1
  2. package/assert.cjs.map +1 -1
  3. package/assert.js +1 -1
  4. package/assert.js.map +1 -1
  5. package/async.cjs +147 -137
  6. package/async.cjs.map +1 -1
  7. package/async.d.ts +98 -131
  8. package/async.js +147 -137
  9. package/async.js.map +1 -1
  10. package/common.cjs +3 -1
  11. package/common.cjs.map +1 -1
  12. package/common.d.ts +18 -24
  13. package/common.js +3 -1
  14. package/common.js.map +1 -1
  15. package/complex.cjs +1 -0
  16. package/complex.cjs.map +1 -1
  17. package/complex.js +1 -0
  18. package/complex.js.map +1 -1
  19. package/cookie.cjs +1 -1
  20. package/cookie.cjs.map +1 -1
  21. package/cookie.d.ts +0 -18
  22. package/cookie.js +1 -1
  23. package/cookie.js.map +1 -1
  24. package/css-cx.cjs +78 -0
  25. package/css-cx.cjs.map +1 -0
  26. package/css-cx.d.ts +69 -0
  27. package/css-cx.js +74 -0
  28. package/css-cx.js.map +1 -0
  29. package/css.cjs +32 -111
  30. package/css.cjs.map +1 -1
  31. package/css.d.ts +32 -42
  32. package/css.js +30 -107
  33. package/css.js.map +1 -1
  34. package/data.cjs +60 -50
  35. package/data.cjs.map +1 -1
  36. package/data.d.ts +21 -34
  37. package/data.js +60 -50
  38. package/data.js.map +1 -1
  39. package/date-time.cjs +104 -98
  40. package/date-time.cjs.map +1 -1
  41. package/date-time.d.ts +51 -57
  42. package/date-time.js +104 -97
  43. package/date-time.js.map +1 -1
  44. package/device.cjs +14 -19
  45. package/device.cjs.map +1 -1
  46. package/device.d.ts +15 -26
  47. package/device.js +14 -19
  48. package/device.js.map +1 -1
  49. package/encodings.cjs +1 -1
  50. package/encodings.cjs.map +1 -1
  51. package/encodings.d.ts +0 -17
  52. package/encodings.js +1 -1
  53. package/encodings.js.map +1 -1
  54. package/errors.cjs +1 -18
  55. package/errors.cjs.map +1 -1
  56. package/errors.d.ts +0 -17
  57. package/errors.js +1 -17
  58. package/errors.js.map +1 -1
  59. package/file.cjs +3 -17
  60. package/file.cjs.map +1 -1
  61. package/file.d.ts +1 -16
  62. package/file.js +3 -17
  63. package/file.js.map +1 -1
  64. package/format.cjs +1 -1
  65. package/format.cjs.map +1 -1
  66. package/format.js +1 -1
  67. package/format.js.map +1 -1
  68. package/html.cjs +113 -173
  69. package/html.cjs.map +1 -1
  70. package/html.d.ts +68 -58
  71. package/html.js +112 -170
  72. package/html.js.map +1 -1
  73. package/id-nanoid.cjs +36 -0
  74. package/id-nanoid.cjs.map +1 -0
  75. package/id-nanoid.d.ts +26 -0
  76. package/id-nanoid.js +32 -0
  77. package/id-nanoid.js.map +1 -0
  78. package/id.cjs +10 -45
  79. package/id.cjs.map +1 -1
  80. package/id.d.ts +27 -36
  81. package/id.js +6 -40
  82. package/id.js.map +1 -1
  83. package/imports.cjs +3 -18
  84. package/imports.cjs.map +1 -1
  85. package/imports.d.ts +1 -16
  86. package/imports.js +3 -17
  87. package/imports.js.map +1 -1
  88. package/math.cjs +16 -12
  89. package/math.cjs.map +1 -1
  90. package/math.d.ts +9 -24
  91. package/math.js +16 -12
  92. package/math.js.map +1 -1
  93. package/media.cjs +88 -89
  94. package/media.cjs.map +1 -1
  95. package/media.d.ts +72 -80
  96. package/media.js +88 -88
  97. package/media.js.map +1 -1
  98. package/mobx.cjs +0 -1
  99. package/mobx.cjs.map +1 -1
  100. package/mobx.js.map +1 -1
  101. package/ms.cjs +3 -17
  102. package/ms.cjs.map +1 -1
  103. package/ms.d.ts +1 -16
  104. package/ms.js +3 -17
  105. package/ms.js.map +1 -1
  106. package/number.cjs +1 -17
  107. package/number.cjs.map +1 -1
  108. package/number.d.ts +0 -16
  109. package/number.js +1 -17
  110. package/number.js.map +1 -1
  111. package/package.json +6 -6
  112. package/parser.cjs +1 -1
  113. package/parser.cjs.map +1 -1
  114. package/parser.js +1 -1
  115. package/parser.js.map +1 -1
  116. package/price.cjs +1 -1
  117. package/price.cjs.map +1 -1
  118. package/price.d.ts +0 -16
  119. package/price.js +1 -1
  120. package/price.js.map +1 -1
  121. package/random.cjs +37 -39
  122. package/random.cjs.map +1 -1
  123. package/random.d.ts +31 -40
  124. package/random.js +37 -39
  125. package/random.js.map +1 -1
  126. package/react.cjs +0 -1
  127. package/react.cjs.map +1 -1
  128. package/react.js.map +1 -1
  129. package/sanitize-html.cjs +82 -0
  130. package/sanitize-html.cjs.map +1 -0
  131. package/sanitize-html.d.ts +28 -0
  132. package/sanitize-html.js +79 -0
  133. package/sanitize-html.js.map +1 -0
  134. package/sound.cjs +1 -17
  135. package/sound.cjs.map +1 -1
  136. package/sound.d.ts +0 -16
  137. package/sound.js +1 -17
  138. package/sound.js.map +1 -1
  139. package/storage.cjs +7 -5
  140. package/storage.cjs.map +1 -1
  141. package/storage.d.ts +3 -17
  142. package/storage.js +7 -5
  143. package/storage.js.map +1 -1
  144. package/text.cjs +3 -17
  145. package/text.cjs.map +1 -1
  146. package/text.d.ts +1 -16
  147. package/text.js +3 -17
  148. package/text.js.map +1 -1
  149. package/type-guard.cjs +38 -1
  150. package/type-guard.cjs.map +1 -1
  151. package/type-guard.d.ts +38 -0
  152. package/type-guard.js +38 -1
  153. package/type-guard.js.map +1 -1
  154. package/types.d.ts +10 -1
  155. package/types.global.d.ts +9 -0
  156. package/vibrate.cjs +1 -17
  157. package/vibrate.cjs.map +1 -1
  158. package/vibrate.d.ts +0 -16
  159. package/vibrate.js +1 -17
  160. package/vibrate.js.map +1 -1
  161. /package/{chunk-pbuEa-1d.js → chunk-D7D4PA-g.js} +0 -0
  162. /package/{chunk-CZWwpsFl.cjs → chunk-DakpK96I.cjs} +0 -0
package/type-guard.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"type-guard.js","names":[],"sources":["../src/type-guard/_exports.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/type-guard\n *\n * ## Description\n *\n * Runtime **type guards** and narrowers for primitives, DOM nodes, `NaN`, and common app values.\n * Each helper is implemented once with consistent `typeof` / `Object.prototype.toString` logic so\n * `unknown` from JSON, events, or third-party scripts becomes safe typed branches without ad-hoc\n * checks scattered through the codebase.\n *\n * ## Usage\n *\n * ```ts\n * import { typeGuard } from \"yummies/type-guard\";\n * ```\n */\n\nimport type {\n AnyFunction,\n AnyObject,\n FalsyValues,\n ValueOf,\n} from 'yummies/types';\n\nconst TYPE = {\n Null: 'null',\n Undefined: 'undefined',\n NaN: 'nan',\n Object: '[object Object]',\n Array: '[object Array]',\n String: '[object String]',\n Number: '[object Number]',\n Boolean: '[object Boolean]',\n Function: '[object Function]',\n AsyncFunction: '[object AsyncFunction]',\n RegExp: '[object RegExp]',\n Symbol: '[object Symbol]',\n Infinite: 'infinite',\n Element: 'element',\n};\n\ntype Type = ValueOf<typeof TYPE>;\n\nfunction getType(value: unknown): Type {\n if (value === undefined) {\n return TYPE.Undefined;\n }\n if (value === null) {\n return TYPE.Null;\n }\n\n // handle DOM elements\n // @ts-expect-error\n if (value && (value.nodeType === 1 || value.nodeType === 9)) {\n return TYPE.Element;\n }\n\n const stringifiedValue = Object.prototype.toString.call(value);\n\n // handle NaN and Infinity\n if (stringifiedValue === TYPE.Number) {\n if (Number.isNaN(value as number)) {\n return TYPE.NaN;\n }\n if (!Number.isFinite(value as number)) {\n return TYPE.Infinite;\n }\n }\n\n return stringifiedValue as Type;\n}\n\nconst createTypeGuard =\n <T>(...types: Type[]) =>\n (value: unknown): value is T =>\n types.includes(getType(value));\n\n/**\n * Checks that a value is neither `null` nor `undefined`.\n *\n * @template T Value type without nullish branches.\n * @param value Value to test.\n * @returns `true` when the value is defined.\n *\n * @example\n * ```ts\n * isDefined(0); // true\n * ```\n *\n * @example\n * ```ts\n * isDefined(null); // false\n * ```\n */\nexport const isDefined = <T>(value: T | undefined | null): value is T =>\n value != null;\n\n/**\n * Checks whether a value is truthy (`!!value`).\n *\n * @param value Value to test.\n * @returns `true` when `!!value` is true.\n *\n * @example\n * ```ts\n * isTruthy(1); // true\n * ```\n *\n * @example\n * ```ts\n * isTruthy(0); // false\n * ```\n */\nexport const isTruthy = <T>(value: T): value is Exclude<T, FalsyValues> =>\n !!value;\n\n/**\n * Checks whether a value is falsy (`!Boolean(value)`).\n *\n * @param value Value to test.\n * @returns `true` when `Boolean(value)` is false.\n *\n * @example\n * ```ts\n * isFalsy(null); // true\n * ```\n *\n * @example\n * ```ts\n * isFalsy(\"x\"); // false\n * ```\n */\nexport const isFalsy = <T>(value: T): value is Extract<T, FalsyValues> =>\n !value;\n\n/**\n * Checks whether a value is exactly `null`.\n *\n * @param value Value to test.\n * @returns `true` when the value is `null`.\n *\n * @example\n * ```ts\n * isNull(null); // true\n * ```\n *\n * @example\n * ```ts\n * isNull(undefined); // false\n * ```\n */\nexport const isNull = createTypeGuard<null>(TYPE.Null);\n\n/**\n * Checks whether a value is exactly `undefined`.\n *\n * @param value Value to test.\n * @returns `true` when the value is `undefined`.\n *\n * @example\n * ```ts\n * isUndefined(undefined); // true\n * ```\n *\n * @example\n * ```ts\n * isUndefined('value'); // false\n * ```\n */\nexport const isUndefined = createTypeGuard<undefined>(TYPE.Undefined);\n\n/**\n * Checks whether a value is a plain object.\n *\n * @param value Value to test.\n * @returns `true` when the value matches `[object Object]`.\n *\n * @example\n * ```ts\n * isObject({ id: 1 }); // true\n * ```\n *\n * @example\n * ```ts\n * isObject([]); // false\n * ```\n */\nexport const isObject = createTypeGuard<AnyObject>(TYPE.Object);\n\n/**\n * Checks whether a value is an array.\n *\n * @param value Value to test.\n * @returns `true` when the value is an array.\n *\n * @example\n * ```ts\n * isArray([1, 2, 3]); // true\n * ```\n *\n * @example\n * ```ts\n * isArray({ length: 1 }); // false\n * ```\n */\nexport const isArray = createTypeGuard<unknown[]>(TYPE.Array);\n\n/**\n * Checks whether a value is a string object or primitive string.\n *\n * @param value Value to test.\n * @returns `true` when the value is a string.\n *\n * @example\n * ```ts\n * isString('hello'); // true\n * ```\n *\n * @example\n * ```ts\n * isString(123); // false\n * ```\n */\nexport const isString = createTypeGuard<string>(TYPE.String);\n\n/**\n * Checks whether a value is a finite number.\n *\n * Unlike `isNaN` and `isInfinite`, this guard only matches regular numeric values.\n *\n * @param value Value to test.\n * @returns `true` when the value is a non-NaN finite number.\n *\n * @example\n * ```ts\n * isNumber(123); // true\n * ```\n *\n * @example\n * ```ts\n * isNumber(Number.NaN); // false\n * ```\n */\nexport const isNumber = createTypeGuard<number>(TYPE.Number);\n\n/**\n * Checks whether a value is a boolean.\n *\n * @param value Value to test.\n * @returns `true` when the value is a boolean.\n *\n * @example\n * ```ts\n * isBoolean(true); // true\n * ```\n *\n * @example\n * ```ts\n * isBoolean('true'); // false\n * ```\n */\nexport const isBoolean = createTypeGuard<boolean>(TYPE.Boolean);\n\n/**\n * Checks whether a value is a synchronous or asynchronous function.\n *\n * @param value Value to test.\n * @returns `true` when the value is a function.\n *\n * @example\n * ```ts\n * isFunction(() => {}); // true\n * ```\n *\n * @example\n * ```ts\n * isFunction(async () => {}); // true\n * ```\n */\nexport const isFunction = createTypeGuard<AnyFunction>(\n TYPE.Function,\n TYPE.AsyncFunction,\n);\n\n/**\n * Checks whether a value is a regular expression.\n *\n * @param value Value to test.\n * @returns `true` when the value is a `RegExp`.\n *\n * @example\n * ```ts\n * isRegExp(/foo/); // true\n * ```\n *\n * @example\n * ```ts\n * isRegExp('foo'); // false\n * ```\n */\nexport const isRegExp = createTypeGuard<RegExp>(TYPE.RegExp);\n\n/**\n * Checks whether a value looks like a DOM element or document node.\n *\n * @param value Value to test.\n * @returns `true` when the value has an element-like node type.\n *\n * @example\n * ```ts\n * isElement(document.body); // true\n * ```\n *\n * @example\n * ```ts\n * isElement({ nodeType: 3 }); // false\n * ```\n */\nexport const isElement = createTypeGuard<HTMLElement>(TYPE.Element);\n\n/**\n * Checks whether a value is `NaN`.\n *\n * @param value Value to test.\n * @returns `true` when the value is `NaN`.\n *\n * @example\n * ```ts\n * isNaN(Number.NaN); // true\n * ```\n *\n * @example\n * ```ts\n * isNaN(5); // false\n * ```\n */\nexport const isNaN = createTypeGuard<number>(TYPE.NaN) as (\n value: unknown,\n) => boolean;\n\n/**\n * Checks whether a value is positive or negative infinity.\n *\n * @param value Value to test.\n * @returns `true` when the value is not finite.\n *\n * @example\n * ```ts\n * isInfinite(Infinity); // true\n * ```\n *\n * @example\n * ```ts\n * isInfinite(10); // false\n * ```\n */\nexport const isInfinite = createTypeGuard<number>(TYPE.Infinite) as (\n value: unknown,\n) => boolean;\n\n/**\n * Checks whether a value is a symbol.\n *\n * @param value Value to test.\n * @returns `true` when the value is a symbol.\n *\n * @example\n * ```ts\n * isSymbol(Symbol('id')); // true\n * ```\n *\n * @example\n * ```ts\n * isSymbol('id'); // false\n * ```\n */\nexport const isSymbol = createTypeGuard<symbol>(TYPE.Symbol);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyBA,IAAM,OAAO;CACX,MAAM;CACN,WAAW;CACX,KAAK;CACL,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,UAAU;CACV,eAAe;CACf,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,SAAS;CACV;AAID,SAAS,QAAQ,OAAsB;AACrC,KAAI,UAAU,KAAA,EACZ,QAAO,KAAK;AAEd,KAAI,UAAU,KACZ,QAAO,KAAK;AAKd,KAAI,UAAU,MAAM,aAAa,KAAK,MAAM,aAAa,GACvD,QAAO,KAAK;CAGd,MAAM,mBAAmB,OAAO,UAAU,SAAS,KAAK,MAAM;AAG9D,KAAI,qBAAqB,KAAK,QAAQ;AACpC,MAAI,OAAO,MAAM,MAAgB,CAC/B,QAAO,KAAK;AAEd,MAAI,CAAC,OAAO,SAAS,MAAgB,CACnC,QAAO,KAAK;;AAIhB,QAAO;;AAGT,IAAM,mBACA,GAAG,WACN,UACC,MAAM,SAAS,QAAQ,MAAM,CAAC;;;;;;;;;;;;;;;;;;AAmBlC,IAAa,aAAgB,UAC3B,SAAS;;;;;;;;;;;;;;;;;AAkBX,IAAa,YAAe,UAC1B,CAAC,CAAC;;;;;;;;;;;;;;;;;AAkBJ,IAAa,WAAc,UACzB,CAAC;;;;;;;;;;;;;;;;;AAkBH,IAAa,SAAS,gBAAsB,KAAK,KAAK;;;;;;;;;;;;;;;;;AAkBtD,IAAa,cAAc,gBAA2B,KAAK,UAAU;;;;;;;;;;;;;;;;;AAkBrE,IAAa,WAAW,gBAA2B,KAAK,OAAO;;;;;;;;;;;;;;;;;AAkB/D,IAAa,UAAU,gBAA2B,KAAK,MAAM;;;;;;;;;;;;;;;;;AAkB7D,IAAa,WAAW,gBAAwB,KAAK,OAAO;;;;;;;;;;;;;;;;;;;AAoB5D,IAAa,WAAW,gBAAwB,KAAK,OAAO;;;;;;;;;;;;;;;;;AAkB5D,IAAa,YAAY,gBAAyB,KAAK,QAAQ;;;;;;;;;;;;;;;;;AAkB/D,IAAa,aAAa,gBACxB,KAAK,UACL,KAAK,cACN;;;;;;;;;;;;;;;;;AAkBD,IAAa,WAAW,gBAAwB,KAAK,OAAO;;;;;;;;;;;;;;;;;AAkB5D,IAAa,YAAY,gBAA6B,KAAK,QAAQ;;;;;;;;;;;;;;;;;AAkBnE,IAAa,QAAQ,gBAAwB,KAAK,IAAI;;;;;;;;;;;;;;;;;AAoBtD,IAAa,aAAa,gBAAwB,KAAK,SAAS;;;;;;;;;;;;;;;;;AAoBhE,IAAa,WAAW,gBAAwB,KAAK,OAAO"}
1
+ {"version":3,"file":"type-guard.js","names":[],"sources":["../src/type-guard/_exports.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/type-guard\n *\n * ## Description\n *\n * Runtime **type guards** and narrowers for primitives, DOM nodes, `NaN`, and common app values.\n * Each helper is implemented once with consistent `typeof` / `Object.prototype.toString` logic so\n * `unknown` from JSON, events, or third-party scripts becomes safe typed branches without ad-hoc\n * checks scattered through the codebase.\n *\n * ## Usage\n *\n * ```ts\n * import { typeGuard } from \"yummies/type-guard\";\n * ```\n */\n\nimport type {\n AnyFunction,\n AnyObject,\n FalsyValues,\n ValueOf,\n} from 'yummies/types';\n\nconst TYPE = {\n Null: 'null',\n Undefined: 'undefined',\n NaN: 'nan',\n Object: '[object Object]',\n Array: '[object Array]',\n String: '[object String]',\n Number: '[object Number]',\n Boolean: '[object Boolean]',\n Function: '[object Function]',\n AsyncFunction: '[object AsyncFunction]',\n RegExp: '[object RegExp]',\n Symbol: '[object Symbol]',\n Infinite: 'infinite',\n Element: 'element',\n};\n\ntype Type = ValueOf<typeof TYPE>;\n\nfunction getType(value: unknown): Type {\n if (value === undefined) {\n return TYPE.Undefined;\n }\n if (value === null) {\n return TYPE.Null;\n }\n\n // handle DOM elements\n // @ts-expect-error\n if (value && (value.nodeType === 1 || value.nodeType === 9)) {\n return TYPE.Element;\n }\n\n const stringifiedValue = Object.prototype.toString.call(value);\n\n // handle NaN and Infinity\n if (stringifiedValue === TYPE.Number) {\n if (Number.isNaN(value as number)) {\n return TYPE.NaN;\n }\n if (!Number.isFinite(value as number)) {\n return TYPE.Infinite;\n }\n }\n\n return stringifiedValue as Type;\n}\n\nconst createTypeGuard =\n <T>(...types: Type[]) =>\n (value: unknown): value is T =>\n types.includes(getType(value));\n\n/**\n * Checks that a value is neither `null` nor `undefined`.\n *\n * @template T Value type without nullish branches.\n * @param value Value to test.\n * @returns `true` when the value is defined.\n *\n * @example\n * ```ts\n * isDefined(0); // true\n * ```\n *\n * @example\n * ```ts\n * isDefined(null); // false\n * ```\n */\nexport const isDefined = <T>(value: T | undefined | null): value is T =>\n value != null;\n\n/**\n * Checks whether a value is truthy (`!!value`).\n *\n * @param value Value to test.\n * @returns `true` when `!!value` is true.\n *\n * @example\n * ```ts\n * isTruthy(1); // true\n * ```\n *\n * @example\n * ```ts\n * isTruthy(0); // false\n * ```\n */\nexport const isTruthy = <T>(value: T): value is Exclude<T, FalsyValues> =>\n !!value;\n\n/**\n * Checks whether a value is falsy (`!Boolean(value)`).\n *\n * @param value Value to test.\n * @returns `true` when `Boolean(value)` is false.\n *\n * @example\n * ```ts\n * isFalsy(null); // true\n * ```\n *\n * @example\n * ```ts\n * isFalsy(\"x\"); // false\n * ```\n */\nexport const isFalsy = <T>(value: T): value is Extract<T, FalsyValues> =>\n !value;\n\n/**\n * Checks whether a value is exactly `null`.\n *\n * @param value Value to test.\n * @returns `true` when the value is `null`.\n *\n * @example\n * ```ts\n * isNull(null); // true\n * ```\n *\n * @example\n * ```ts\n * isNull(undefined); // false\n * ```\n */\nexport const isNull = createTypeGuard<null>(TYPE.Null);\n\n/**\n * Checks whether a value is exactly `undefined`.\n *\n * @param value Value to test.\n * @returns `true` when the value is `undefined`.\n *\n * @example\n * ```ts\n * isUndefined(undefined); // true\n * ```\n *\n * @example\n * ```ts\n * isUndefined('value'); // false\n * ```\n */\nexport const isUndefined = createTypeGuard<undefined>(TYPE.Undefined);\n\n/**\n * Checks whether a value is a plain object.\n *\n * @param value Value to test.\n * @returns `true` when the value matches `[object Object]`.\n *\n * @example\n * ```ts\n * isObject({ id: 1 }); // true\n * ```\n *\n * @example\n * ```ts\n * isObject([]); // false\n * ```\n */\nexport const isObject = createTypeGuard<AnyObject>(TYPE.Object);\n\n/**\n * Checks whether a value is object-like: non-null and `typeof value === 'object'`.\n *\n * This includes plain objects, arrays, `Date`, `RegExp`, boxed primitives, and other built-ins\n * whose `typeof` is `\"object\"`. It is broader than `isObject`, which only matches plain objects.\n *\n * @template T Input value type.\n * @param value Value to test.\n * @returns `true` when the value is a non-null object.\n *\n * @example\n * ```ts\n * isObjectLike({ a: 1 }); // true\n * ```\n *\n * @example\n * ```ts\n * isObjectLike([]); // true\n * ```\n *\n * @example\n * ```ts\n * isObjectLike(new Date()); // true\n * ```\n *\n * @example\n * ```ts\n * isObjectLike(null); // false\n * ```\n *\n * @example\n * ```ts\n * isObjectLike(() => {}); // false\n * ```\n */\nexport const isObjectLike = <T = never>(\n value: unknown,\n): value is T extends never ? Extract<typeof value, object> : T =>\n typeof value === 'object' && !!value;\n\n/**\n * Checks whether a value is an array.\n *\n * @param value Value to test.\n * @returns `true` when the value is an array.\n *\n * @example\n * ```ts\n * isArray([1, 2, 3]); // true\n * ```\n *\n * @example\n * ```ts\n * isArray({ length: 1 }); // false\n * ```\n */\nexport const isArray = createTypeGuard<unknown[]>(TYPE.Array);\n\n/**\n * Checks whether a value is a string object or primitive string.\n *\n * @param value Value to test.\n * @returns `true` when the value is a string.\n *\n * @example\n * ```ts\n * isString('hello'); // true\n * ```\n *\n * @example\n * ```ts\n * isString(123); // false\n * ```\n */\nexport const isString = createTypeGuard<string>(TYPE.String);\n\n/**\n * Checks whether a value is a finite number.\n *\n * Unlike `isNaN` and `isInfinite`, this guard only matches regular numeric values.\n *\n * @param value Value to test.\n * @returns `true` when the value is a non-NaN finite number.\n *\n * @example\n * ```ts\n * isNumber(123); // true\n * ```\n *\n * @example\n * ```ts\n * isNumber(Number.NaN); // false\n * ```\n */\nexport const isNumber = createTypeGuard<number>(TYPE.Number);\n\n/**\n * Checks whether a value is a boolean.\n *\n * @param value Value to test.\n * @returns `true` when the value is a boolean.\n *\n * @example\n * ```ts\n * isBoolean(true); // true\n * ```\n *\n * @example\n * ```ts\n * isBoolean('true'); // false\n * ```\n */\nexport const isBoolean = createTypeGuard<boolean>(TYPE.Boolean);\n\n/**\n * Checks whether a value is a synchronous or asynchronous function.\n *\n * @param value Value to test.\n * @returns `true` when the value is a function.\n *\n * @example\n * ```ts\n * isFunction(() => {}); // true\n * ```\n *\n * @example\n * ```ts\n * isFunction(async () => {}); // true\n * ```\n */\nexport const isFunction = createTypeGuard<AnyFunction>(\n TYPE.Function,\n TYPE.AsyncFunction,\n);\n\n/**\n * Checks whether a value is a regular expression.\n *\n * @param value Value to test.\n * @returns `true` when the value is a `RegExp`.\n *\n * @example\n * ```ts\n * isRegExp(/foo/); // true\n * ```\n *\n * @example\n * ```ts\n * isRegExp('foo'); // false\n * ```\n */\nexport const isRegExp = createTypeGuard<RegExp>(TYPE.RegExp);\n\n/**\n * Checks whether a value looks like a DOM element or document node.\n *\n * @param value Value to test.\n * @returns `true` when the value has an element-like node type.\n *\n * @example\n * ```ts\n * isElement(document.body); // true\n * ```\n *\n * @example\n * ```ts\n * isElement({ nodeType: 3 }); // false\n * ```\n */\nexport const isElement = createTypeGuard<HTMLElement>(TYPE.Element);\n\n/**\n * Checks whether a value is `NaN`.\n *\n * @param value Value to test.\n * @returns `true` when the value is `NaN`.\n *\n * @example\n * ```ts\n * isNaN(Number.NaN); // true\n * ```\n *\n * @example\n * ```ts\n * isNaN(5); // false\n * ```\n */\nexport const isNaN = createTypeGuard<number>(TYPE.NaN) as (\n value: unknown,\n) => boolean;\n\n/**\n * Checks whether a value is positive or negative infinity.\n *\n * @param value Value to test.\n * @returns `true` when the value is not finite.\n *\n * @example\n * ```ts\n * isInfinite(Infinity); // true\n * ```\n *\n * @example\n * ```ts\n * isInfinite(10); // false\n * ```\n */\nexport const isInfinite = createTypeGuard<number>(TYPE.Infinite) as (\n value: unknown,\n) => boolean;\n\n/**\n * Checks whether a value is a symbol.\n *\n * @param value Value to test.\n * @returns `true` when the value is a symbol.\n *\n * @example\n * ```ts\n * isSymbol(Symbol('id')); // true\n * ```\n *\n * @example\n * ```ts\n * isSymbol('id'); // false\n * ```\n */\nexport const isSymbol = createTypeGuard<symbol>(TYPE.Symbol);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBA,IAAM,OAAO;CACX,MAAM;CACN,WAAW;CACX,KAAK;CACL,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,UAAU;CACV,eAAe;CACf,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,SAAS;AACX;AAIA,SAAS,QAAQ,OAAsB;CACrC,IAAI,UAAU,KAAA,GACZ,OAAO,KAAK;CAEd,IAAI,UAAU,MACZ,OAAO,KAAK;CAKd,IAAI,UAAU,MAAM,aAAa,KAAK,MAAM,aAAa,IACvD,OAAO,KAAK;CAGd,MAAM,mBAAmB,OAAO,UAAU,SAAS,KAAK,KAAK;CAG7D,IAAI,qBAAqB,KAAK,QAAQ;EACpC,IAAI,OAAO,MAAM,KAAe,GAC9B,OAAO,KAAK;EAEd,IAAI,CAAC,OAAO,SAAS,KAAe,GAClC,OAAO,KAAK;CAEhB;CAEA,OAAO;AACT;AAEA,IAAM,mBACA,GAAG,WACN,UACC,MAAM,SAAS,QAAQ,KAAK,CAAC;;;;;;;;;;;;;;;;;;AAmBjC,IAAa,aAAgB,UAC3B,SAAS;;;;;;;;;;;;;;;;;AAkBX,IAAa,YAAe,UAC1B,CAAC,CAAC;;;;;;;;;;;;;;;;;AAkBJ,IAAa,WAAc,UACzB,CAAC;;;;;;;;;;;;;;;;;AAkBH,IAAa,SAAS,gBAAsB,KAAK,IAAI;;;;;;;;;;;;;;;;;AAkBrD,IAAa,cAAc,gBAA2B,KAAK,SAAS;;;;;;;;;;;;;;;;;AAkBpE,IAAa,WAAW,gBAA2B,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqC9D,IAAa,gBACX,UAEA,OAAO,UAAU,YAAY,CAAC,CAAC;;;;;;;;;;;;;;;;;AAkBjC,IAAa,UAAU,gBAA2B,KAAK,KAAK;;;;;;;;;;;;;;;;;AAkB5D,IAAa,WAAW,gBAAwB,KAAK,MAAM;;;;;;;;;;;;;;;;;;;AAoB3D,IAAa,WAAW,gBAAwB,KAAK,MAAM;;;;;;;;;;;;;;;;;AAkB3D,IAAa,YAAY,gBAAyB,KAAK,OAAO;;;;;;;;;;;;;;;;;AAkB9D,IAAa,aAAa,gBACxB,KAAK,UACL,KAAK,aACP;;;;;;;;;;;;;;;;;AAkBA,IAAa,WAAW,gBAAwB,KAAK,MAAM;;;;;;;;;;;;;;;;;AAkB3D,IAAa,YAAY,gBAA6B,KAAK,OAAO;;;;;;;;;;;;;;;;;AAkBlE,IAAa,QAAQ,gBAAwB,KAAK,GAAG;;;;;;;;;;;;;;;;;AAoBrD,IAAa,aAAa,gBAAwB,KAAK,QAAQ;;;;;;;;;;;;;;;;;AAoB/D,IAAa,WAAW,gBAAwB,KAAK,MAAM"}
package/types.d.ts CHANGED
@@ -495,5 +495,14 @@ type AnyBoolean = boolean & {};
495
495
  * and leave the rest of the string unchanged.
496
496
  */
497
497
  type UpperFirst<S extends string> = S extends `${infer F}${infer R}` ? `${Uppercase<F>}${R}` : S;
498
+ type RequiredPropertyIfNeeded<TPropertyName extends string, TPropertyValue> = TPropertyValue extends undefined ? {
499
+ [P in TPropertyName]?: TPropertyValue;
500
+ } : TPropertyValue extends AnyObject ? IsPartial<TPropertyValue> extends true ? {
501
+ [P in TPropertyName]?: TPropertyValue;
502
+ } : {
503
+ [P in TPropertyName]: TPropertyValue;
504
+ } : {
505
+ [P in TPropertyName]: TPropertyValue;
506
+ };
498
507
 
499
- export type { AllPropertiesOptional, AnyBoolean, AnyFunction, AnyNumber, AnyObject, AnyPrimitive, AnyString, BrowserNativeObject, Class, CopyObject, DeepPartial, Defined, Dict, EmptyObject, ExtractEnumKeys, ExtractEnumValues, ExtractObjects, FalsyValues, Fn, HasKey, HasSpecificKey, IfEquals, IndexKeys, IsAny, IsArray, IsEmptyArray, IsFunction, IsObject, IsObjectEmpty, IsPartial, IsUnknown, KeyOfByValue, LiteralUnion, Maybe, MaybeArray, MaybeFalsy, MaybeFn, MaybeKeys, MaybePromise, MaybeValues, NonReadonly, NonUndefined, NotMaybe, NotNullable, Nullable, OmitByValue, OverrideKey, Params, PartialIf, PartialKeys, PickByValue, Primitive, ReadonlyKeys, RecordEntries, RenameKey, RequiredKeys, UnionToIntersection, Unpromise, UpperFirst, ValueOf, WithRequired, WritableKeys };
508
+ export type { AllPropertiesOptional, AnyBoolean, AnyFunction, AnyNumber, AnyObject, AnyPrimitive, AnyString, BrowserNativeObject, Class, CopyObject, DeepPartial, Defined, Dict, EmptyObject, ExtractEnumKeys, ExtractEnumValues, ExtractObjects, FalsyValues, Fn, HasKey, HasSpecificKey, IfEquals, IndexKeys, IsAny, IsArray, IsEmptyArray, IsFunction, IsObject, IsObjectEmpty, IsPartial, IsUnknown, KeyOfByValue, LiteralUnion, Maybe, MaybeArray, MaybeFalsy, MaybeFn, MaybeKeys, MaybePromise, MaybeValues, NonReadonly, NonUndefined, NotMaybe, NotNullable, Nullable, OmitByValue, OverrideKey, Params, PartialIf, PartialKeys, PickByValue, Primitive, ReadonlyKeys, RecordEntries, RenameKey, RequiredKeys, RequiredPropertyIfNeeded, UnionToIntersection, Unpromise, UpperFirst, ValueOf, WithRequired, WritableKeys };
package/types.global.d.ts CHANGED
@@ -496,4 +496,13 @@ type AnyBoolean = boolean & {};
496
496
  * and leave the rest of the string unchanged.
497
497
  */
498
498
  type UpperFirst<S extends string> = S extends `${infer F}${infer R}` ? `${Uppercase<F>}${R}` : S;
499
+ type RequiredPropertyIfNeeded<TPropertyName extends string, TPropertyValue> = TPropertyValue extends undefined ? {
500
+ [P in TPropertyName]?: TPropertyValue;
501
+ } : TPropertyValue extends AnyObject ? IsPartial<TPropertyValue> extends true ? {
502
+ [P in TPropertyName]?: TPropertyValue;
503
+ } : {
504
+ [P in TPropertyName]: TPropertyValue;
505
+ } : {
506
+ [P in TPropertyName]: TPropertyValue;
507
+ };
499
508
 
package/vibrate.cjs CHANGED
@@ -1,21 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/vibrate.ts
3
- /**
4
- * ---header-docs-section---
5
- * # yummies/vibrate
6
- *
7
- * ## Description
8
- *
9
- * Thin wrapper around **`navigator.vibrate`** for mobile-style haptics: single pulses or patterned
10
- * on/off sequences. It no-ops when the API is missing or disabled, so UI code stays simple. Do not
11
- * rely on vibration for critical feedback because iOS and many desktops omit the API entirely.
12
- *
13
- * ## Usage
14
- *
15
- * ```ts
16
- * import { vibrate } from "yummies/vibrate";
17
- * ```
18
- */
2
+ //#region src/vibrate/vibrate.ts
19
3
  /**
20
4
  * Triggers haptic feedback via the {@link https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API | Vibration API}
21
5
  * when `navigator.vibrate` exists (common on Android Chrome; often missing on iOS Safari / desktop).
package/vibrate.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vibrate.cjs","names":[],"sources":["../src/vibrate.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/vibrate\n *\n * ## Description\n *\n * Thin wrapper around **`navigator.vibrate`** for mobile-style haptics: single pulses or patterned\n * on/off sequences. It no-ops when the API is missing or disabled, so UI code stays simple. Do not\n * rely on vibration for critical feedback because iOS and many desktops omit the API entirely.\n *\n * ## Usage\n *\n * ```ts\n * import { vibrate } from \"yummies/vibrate\";\n * ```\n */\n\n/**\n * Triggers haptic feedback via the {@link https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API | Vibration API}\n * when `navigator.vibrate` exists (common on Android Chrome; often missing on iOS Safari / desktop).\n *\n * - **Single number** — vibrate for that many milliseconds, then stop.\n * - **Array of numbers** — alternating vibration and pause lengths in ms: `[vibrate, pause, vibrate, ...]`.\n * Per the spec, values are clamped; odd-length arrays imply a trailing vibrate segment.\n *\n * If the API is unavailable or the user has disabled vibration, this function **does nothing**\n * (no throw). Call sites should not rely on vibration for critical UX.\n *\n * @param pattern - Duration in ms, or a pattern array as described above.\n *\n * @example\n * Short confirmation buzz (200 ms):\n * ```ts\n * vibrate(200);\n * ```\n *\n * @example\n * Double-pulse pattern: 100 ms on, 50 ms off, 100 ms on:\n * ```ts\n * vibrate([100, 50, 100]);\n * ```\n */\nexport const vibrate = (pattern: number | number[]) => {\n if ('vibrate' in navigator) {\n navigator.vibrate(pattern);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,WAAW,YAA+B;AACrD,KAAI,aAAa,UACf,WAAU,QAAQ,QAAQ"}
1
+ {"version":3,"file":"vibrate.cjs","names":[],"sources":["../src/vibrate/vibrate.ts"],"sourcesContent":["/**\n * Triggers haptic feedback via the {@link https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API | Vibration API}\n * when `navigator.vibrate` exists (common on Android Chrome; often missing on iOS Safari / desktop).\n *\n * - **Single number** — vibrate for that many milliseconds, then stop.\n * - **Array of numbers** — alternating vibration and pause lengths in ms: `[vibrate, pause, vibrate, ...]`.\n * Per the spec, values are clamped; odd-length arrays imply a trailing vibrate segment.\n *\n * If the API is unavailable or the user has disabled vibration, this function **does nothing**\n * (no throw). Call sites should not rely on vibration for critical UX.\n *\n * @param pattern - Duration in ms, or a pattern array as described above.\n *\n * @example\n * Short confirmation buzz (200 ms):\n * ```ts\n * vibrate(200);\n * ```\n *\n * @example\n * Double-pulse pattern: 100 ms on, 50 ms off, 100 ms on:\n * ```ts\n * vibrate([100, 50, 100]);\n * ```\n */\nexport const vibrate = (pattern: number | number[]) => {\n if ('vibrate' in navigator) {\n navigator.vibrate(pattern);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,WAAW,YAA+B;CACrD,IAAI,aAAa,WACf,UAAU,QAAQ,OAAO;AAE7B"}
package/vibrate.d.ts CHANGED
@@ -1,19 +1,3 @@
1
- /**
2
- * ---header-docs-section---
3
- * # yummies/vibrate
4
- *
5
- * ## Description
6
- *
7
- * Thin wrapper around **`navigator.vibrate`** for mobile-style haptics: single pulses or patterned
8
- * on/off sequences. It no-ops when the API is missing or disabled, so UI code stays simple. Do not
9
- * rely on vibration for critical feedback because iOS and many desktops omit the API entirely.
10
- *
11
- * ## Usage
12
- *
13
- * ```ts
14
- * import { vibrate } from "yummies/vibrate";
15
- * ```
16
- */
17
1
  /**
18
2
  * Triggers haptic feedback via the {@link https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API | Vibration API}
19
3
  * when `navigator.vibrate` exists (common on Android Chrome; often missing on iOS Safari / desktop).
package/vibrate.js CHANGED
@@ -1,20 +1,4 @@
1
- //#region src/vibrate.ts
2
- /**
3
- * ---header-docs-section---
4
- * # yummies/vibrate
5
- *
6
- * ## Description
7
- *
8
- * Thin wrapper around **`navigator.vibrate`** for mobile-style haptics: single pulses or patterned
9
- * on/off sequences. It no-ops when the API is missing or disabled, so UI code stays simple. Do not
10
- * rely on vibration for critical feedback because iOS and many desktops omit the API entirely.
11
- *
12
- * ## Usage
13
- *
14
- * ```ts
15
- * import { vibrate } from "yummies/vibrate";
16
- * ```
17
- */
1
+ //#region src/vibrate/vibrate.ts
18
2
  /**
19
3
  * Triggers haptic feedback via the {@link https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API | Vibration API}
20
4
  * when `navigator.vibrate` exists (common on Android Chrome; often missing on iOS Safari / desktop).
package/vibrate.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vibrate.js","names":[],"sources":["../src/vibrate.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/vibrate\n *\n * ## Description\n *\n * Thin wrapper around **`navigator.vibrate`** for mobile-style haptics: single pulses or patterned\n * on/off sequences. It no-ops when the API is missing or disabled, so UI code stays simple. Do not\n * rely on vibration for critical feedback because iOS and many desktops omit the API entirely.\n *\n * ## Usage\n *\n * ```ts\n * import { vibrate } from \"yummies/vibrate\";\n * ```\n */\n\n/**\n * Triggers haptic feedback via the {@link https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API | Vibration API}\n * when `navigator.vibrate` exists (common on Android Chrome; often missing on iOS Safari / desktop).\n *\n * - **Single number** — vibrate for that many milliseconds, then stop.\n * - **Array of numbers** — alternating vibration and pause lengths in ms: `[vibrate, pause, vibrate, ...]`.\n * Per the spec, values are clamped; odd-length arrays imply a trailing vibrate segment.\n *\n * If the API is unavailable or the user has disabled vibration, this function **does nothing**\n * (no throw). Call sites should not rely on vibration for critical UX.\n *\n * @param pattern - Duration in ms, or a pattern array as described above.\n *\n * @example\n * Short confirmation buzz (200 ms):\n * ```ts\n * vibrate(200);\n * ```\n *\n * @example\n * Double-pulse pattern: 100 ms on, 50 ms off, 100 ms on:\n * ```ts\n * vibrate([100, 50, 100]);\n * ```\n */\nexport const vibrate = (pattern: number | number[]) => {\n if ('vibrate' in navigator) {\n navigator.vibrate(pattern);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,WAAW,YAA+B;AACrD,KAAI,aAAa,UACf,WAAU,QAAQ,QAAQ"}
1
+ {"version":3,"file":"vibrate.js","names":[],"sources":["../src/vibrate/vibrate.ts"],"sourcesContent":["/**\n * Triggers haptic feedback via the {@link https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API | Vibration API}\n * when `navigator.vibrate` exists (common on Android Chrome; often missing on iOS Safari / desktop).\n *\n * - **Single number** — vibrate for that many milliseconds, then stop.\n * - **Array of numbers** — alternating vibration and pause lengths in ms: `[vibrate, pause, vibrate, ...]`.\n * Per the spec, values are clamped; odd-length arrays imply a trailing vibrate segment.\n *\n * If the API is unavailable or the user has disabled vibration, this function **does nothing**\n * (no throw). Call sites should not rely on vibration for critical UX.\n *\n * @param pattern - Duration in ms, or a pattern array as described above.\n *\n * @example\n * Short confirmation buzz (200 ms):\n * ```ts\n * vibrate(200);\n * ```\n *\n * @example\n * Double-pulse pattern: 100 ms on, 50 ms off, 100 ms on:\n * ```ts\n * vibrate([100, 50, 100]);\n * ```\n */\nexport const vibrate = (pattern: number | number[]) => {\n if ('vibrate' in navigator) {\n navigator.vibrate(pattern);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,WAAW,YAA+B;CACrD,IAAI,aAAa,WACf,UAAU,QAAQ,OAAO;AAE7B"}
File without changes
File without changes