l0.DependencyControl.utils¶
Functions¶
equals ¶
Deep equality comparison. Tables compared recursively; other types use ==. Circular references are handled. Metatables are included in the comparison.
| param | type | description |
|---|---|---|
| a | any |
|
| b | any |
Returns:
equalboolean
itemsEqual ¶
Compares table items for equality, ignoring keys. By default only numerical indexes are compared.
| param | type | description |
|---|---|---|
| a | table |
|
| b | table |
|
| onlyNumKeys? | boolean |
Compare only sequential numeric indices (default true). |
| ignoreExtraAItems? | boolean |
Allow a to contain items absent from b (default false). |
| requireIdenticalItems? | boolean |
Require identical (not merely equal) table items (default false). |
Returns:
equalboolean
copy ¶
Shallow-copies a table (no metatable).
| param | type | description |
|---|---|---|
| tbl | table |
The table to copy. |
Returns:
copytable— The copied table.
deepCopy ¶
Deep-copies a table recursively (no metatables).
| param | type | description |
|---|---|---|
| tbl | table |
The table to deep-copy. |
Returns:
copytable— The deep-copied table.
makeSet ¶
Builds (or extends) a set from an array's values: each value becomes a key mapped to value.
| param | type | description |
|---|---|---|
| source | any[] |
Array whose values become the set's keys. |
| target? | table |
Table to populate (default a new table). |
| overwrite? | boolean |
Overwrite keys already present in target (default true). |
| value? | any |
Value to map each key to (default true). |
Returns:
settable— The populatedtarget.
listIncludes ¶
Reports whether an array contains a value (compared with ==).
| param | type | description |
|---|---|---|
| list | any[] |
The array to search. |
| value | any |
The value to look for. |
Returns:
includedboolean— Whethervalueis an element oflist.
addDefaults ¶
Fills in missing entries of tbl from defaults, mutating tbl in place.
| param | type | description |
|---|---|---|
| tbl | table |
The table to fill in. |
| defaults | table |
Default key/value pairs. |
| predicate? | fun(value: any, key: any, tbl: table): boolean |
Per-key test for whether to apply the default; when omitted, defaults apply wherever tbl[key] is nil. |
Returns:
addedCountnumber— The number of defaults applied.
trim ¶
Strips leading and trailing whitespace from a string.
| param | type | description |
|---|---|---|
| str | string |
The string to trim. |
Returns:
trimmedstring— The trimmed string.
escapePattern ¶
Escapes all Lua pattern magic characters in a string so it matches literally.
| param | type | description |
|---|---|---|
| str | string |
The string to escape. |
Returns:
escapedstring— The escaped string.
flatten ¶
Flattens nested array tables into a single array up to the specified depth. Values that are not (or not converted to) pure array tables are included as-is.
| param | type | description |
|---|---|---|
| value | any |
The value to flatten. |
| depth? | number |
Maximum depth to flatten (default 1). |
| toArrayTable? | fun(value: any, valueType: string): table?, boolean? |
Converts a non-array value to an array table. |
Returns:
flattenedtable— A flattened array table containing the flattened values.flattenedCountnumber— The number of elements in the flattened array.
mergeSearchPath ¶
Merges new entries into a semicolon-separated Lua search path, appending only the ones not already present and dropping any listed for removal, with the order of kept entries preserved.
| param | type | description |
|---|---|---|
| pathStr | string |
The existing search path, e.g. package.path. |
| add | string[] |
Path entries to append, each only when not already present. |
| remove? | string[] |
Path entries to drop before merging, e.g. to undo an earlier addition. |
Returns:
pathStrstring— The merged search-path string.addedstring[] — The entries actually appended, empty when all were already present.
extendPackagePath ¶
Extends one of package's search-path fields in place, folding in the entries of a semicolon- separated string and appending only those not already present. Does nothing when there is nothing to add.
| param | type | description |
|---|---|---|
| field | "path"|"cpath"|"moonpath" |
Which package search path to extend. |
| entries? | string |
A semicolon-separated path string to fold in, such as an env var's value. |
Returns:
addedstring[] — The entries actually added, empty when all were present or nothing was passed.
getRandomSeed ¶
Returns a random-number seed unique to this script's Lua state, differing from one launch to the next.
Returns:
seednumber
seedRandom ¶
Reseeds this Lua state's random number generator so math.random yields a stream unique to the
script and to this launch. DependencyControl seeds it on load; call this to reseed it yourself.
Returns:
seednumber— The applied seed.
uuid ¶
Generates a random RFC-4122 version-4 UUID string.
Returns:
uuidstring