@untemps/utils 4.0.0-beta.16 → 4.0.0-beta.17

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
@@ -39,4 +39,49 @@ import { interpolate } from '@untemps/utils/string/interpolate'
39
39
 
40
40
  ```js
41
41
  const { isNil } = require('@untemps/utils')
42
- ```
42
+ ```
43
+
44
+ ## Available utilities
45
+
46
+ Every utility is exported both from the package root and per-module at `@untemps/utils/<category>/<name>`. See the [Docs](https://utils.untemps.net) for full signatures, parameters, and examples.
47
+
48
+ ### array
49
+ - **`extractByIndices`** — extract values from an array at the given indices
50
+
51
+ ### async
52
+ - **`debounce`** — delay invocation until after a quiet period; returns a function with `.cancel()`
53
+ - **`standby`** — return a promise that resolves after the given delay
54
+ - **`throttle`** — invoke at most once per interval (leading + trailing); returns a function with `.cancel()`
55
+
56
+ ### dom
57
+ - **`createElement`** — create a DOM element from a configuration object
58
+ - **`doElementsOverlap`** — check whether two DOM elements overlap on screen
59
+ - **`getCSSDeclaration`** — find a CSS rule by class name across `document.styleSheets`
60
+ - **`getElement`** — query a DOM element by selector
61
+ - **`isElement`** — check whether a value is a DOM element
62
+ - **`modifyElement`** — set attributes on a DOM element (by reference or selector)
63
+ - **`removeElement`** — remove a DOM element (by reference or selector)
64
+ - **`resolveClassName`** — aggregate class names from strings or `[condition, ifTrue, ifFalse]` tuples
65
+
66
+ ### function
67
+ - **`isFunction`** — check whether a value is a function
68
+
69
+ ### lang
70
+ - **`isNil`** — check whether a value is `null` or `undefined`
71
+
72
+ ### number
73
+ - **`clamp`** — clamp a number between two bounds
74
+ - **`getRandomInteger`** — return a pseudo-random integer in `[min, max]`
75
+ - **`normalizeMinMax`** — return `[min, max]` ensuring `min <= max`
76
+
77
+ ### object
78
+ - **`deepClone`** — structured-clone deep copy (functions and DOM nodes are not supported)
79
+ - **`deepMerge`** — recursively merge a source into a target with circular-reference support
80
+ - **`isObject`** — check whether a value is a plain object
81
+
82
+ ### string
83
+ - **`generateText`** — generate a string from a dictionary using configurable rules
84
+ - **`generateTokenizedText`** — like `generateText` but also returns token indices
85
+ - **`interpolate`** — replace `%key%`-style tokens in a string
86
+ - **`interpolateLiteral`** — replace `${key}`-style tokens in a literal-like string
87
+ - **`isString`** — check whether a value is a string
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../lang/isNil.cjs`);var t=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=e=>Object.keys(e).map(t).join(`|`),r=(r,i={},a=`%`)=>{let o=t(a),s=n(i),c=s?RegExp(`${o}(${s})${o}`,`g`):/(?!)/g;return r.replace(c,(t,n)=>e.isNil(i[n])?n:String(i[n]))};exports.interpolate=r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../lang/isNil.cjs`);var t=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=e=>Object.keys(e).map(t).join(`|`),r=(r,i={},a=`%`)=>{let o=t(a),s=n(i),c=s?RegExp(`${o}(${s})${o}`,`g`):/(?!)/g;return r.replace(c,(t,n)=>e.isNil(i[n])?t:String(i[n]))};exports.interpolate=r;
@@ -2,7 +2,7 @@ import { isNil as e } from "../lang/isNil.js";
2
2
  //#region src/string/interpolate.ts
3
3
  var t = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), n = (e) => Object.keys(e).map(t).join("|"), r = (r, i = {}, a = "%") => {
4
4
  let o = t(a), s = n(i), c = s ? RegExp(`${o}(${s})${o}`, "g") : /(?!)/g;
5
- return r.replace(c, (t, n) => e(i[n]) ? n : String(i[n]));
5
+ return r.replace(c, (t, n) => e(i[n]) ? t : String(i[n]));
6
6
  };
7
7
  //#endregion
8
8
  export { r as interpolate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@untemps/utils",
3
- "version": "4.0.0-beta.16",
3
+ "version": "4.0.0-beta.17",
4
4
  "description": "Utils for @untemps packages",
5
5
  "repository": "git@github.com:untemps/utils.git",
6
6
  "keywords": [],