Observed since 20 Oct, 22:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0x26e/utils
A TypeScript Utility Collection Similar to Laravel Helpers
@0x26e/utils
A TypeScript Utility Collection Similar to Laravel Helpers.
npm install @0x26e/utils
crossJoin()Returns the Cartesian product of the given arrays. The Cartesian product of multiple sets is a set of all possible combinations where each combination contains one element from each input array.
const result = crossJoin([1, 2], ['a', 'b']);
console.log(result);
// Output: [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
toCssClasses()The toCssClasses function conditionally compiles a CSS class string. The method accepts an object of classes where the object key contains the class or classes you wish to add, while the value is a boolean expression. If the object key has a numeric key, it will always be included in the rendered class list:
const isActive = false;
const hasError = true;
const classes = toCssClasses([
'p-4',
{ 'font-bold': isActive, 'bg-red': hasError },
]);
console.log(classes);
// Output: 'p-4 bg-red'
blank()The blank function determines whether the given value is "blank":
blank('');
blank(' ');
blank(null);
blank(collect());
// true
blank(0);
blank(true);
blank(false);
// false
sleep()Pauses the execution for a specified number of seconds
await sleep(2); // Pauses execution for 2 seconds.
usleep()Pauses the execution for a specified number of milliseconds.
await usleep(500); // Pauses execution for 500 milliseconds.
tap()Invokes an interceptor function with a provided value and returns the result.
const tappedValue = tap(5, (n) => n * 2); // tappedValue = 10
until()Continuously attempts a function until a condition is met.
const result = await until(
() => isConditionTrue(),
() => fetchData(),
2,
);
clamp()Returns a value clamped to the inclusive range of min and max. This function ensures that the value falls within the specified range. If the value
is less than min, it returns min. If the value is greater than max, it returns max.
Otherwise, it returns the value itself.
const clamped1 = clamp(5, 1, 10);
console.log(clamped1); // 5
const clamped2 = clamp(15, 1, 10);
console.log(clamped2); // 10 (since 15 is greater than max 10)
const clamped3 = clamp(-5, 1, 10);
console.log(clamped3); // 1 (since -5 is less than min 1)
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
tsupEnvironment{
"local_name": "tsup",
"alias": false,
"peer_metadata": null
} | ^8.2.4 | development |
vitestEnvironment{
"local_name": "vitest",
"alias": false,
"peer_metadata": null
} | ^2.0.5 | development |
prettierEnvironment{
"local_name": "prettier",
"alias": false,
"peer_metadata": null
} | ^3.3.3 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^5.5.4 | development |
@changesets/cliEnvironment{
"local_name": "@changesets/cli",
"alias": false,
"peer_metadata": null
} | ^2.27.7 | development |
@arethetypeswrong/cliEnvironment{
"local_name": "@arethetypeswrong/cli",
"alias": false,
"peer_metadata": null
} | ^0.15.4 | development |
Source distribution
{
"shasum": "52341abaf8f4a1b0fcd81a05eff7d7817bf19377",
"tarball": "https://registry.npmjs.org/@0x26e/utils/-/utils-1.0.1.tgz",
"fileCount": 7,
"integrity": "sha512-fXX6UapqOI7fm2lFN9qNsMoW2ivvjrX7ValogO74K0t/dDKU4K4gmsGWqq1unTXetbIngSK+3qmAU0qc/2wG9Q==",
"signatures": [
{
"sig": "MEQCIA7xcLL47TG64O3sHSoKK104UQM3i8GRKsuGXEI9CJ0vAiB2fCDX3QldeB30Mpf/SAuSu+wo1C8lkGiYExOi5FX49A==",
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
}
],
"unpackedSize": 5939
}Observed since 20 Oct, 22:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:2a9bacd95df15b287c4728f48c4cd11f339c28093471ef128de82400a0b73c87