@nasriya/atomix
Advanced tools
@@ -216,6 +216,12 @@ export type { Mime, FileExtension } from "../domains/http/mimes/mimes"; | ||
| * | ||
| * β οΈ Unlike `Partial<T>`, this utility makes **only the key optional**, not the value. | ||
| * That means you can omit the property entirely, but you **cannot explicitly assign `undefined`** | ||
| * unless `undefined` is already part of the value type. | ||
| * β οΈ Unlike `Partial<T>`, which makes both keys and their values optional (allowing `undefined`), | ||
| * this utility makes **only the keys optional** β the value types remain unchanged. | ||
| * This means: | ||
| * - You may omit the property entirely. | ||
| * - You **cannot** assign `undefined` explicitly to the property, | ||
| * unless `undefined` is already part of the original value type. | ||
| * | ||
| * If you want to allow both keys and values to be optional (i.e., values can be `undefined`), | ||
| * consider using {@link OptionalLoose}. | ||
| * | ||
| * @template T The original object type. | ||
@@ -240,3 +246,3 @@ * @template I A union of keys from `T` that should remain required. Defaults to `never`. | ||
| * const u1: WithId = { id: '123' }; // β valid | ||
| * const u2: WithId = { id: '123', name: undefined }; // β invalid unless `name: string | undefined` | ||
| * const u2: WithId = { id: '123', name: undefined }; // β invalid unless `name` includes `undefined` | ||
| * | ||
@@ -255,3 +261,52 @@ * type AllOptional = Optional<User>; | ||
| } & { | ||
| [P in keyof T as P extends I ? never : P]?: undefined extends T[P] ? T[P] : Exclude<T[P], undefined>; | ||
| }>; | ||
| /** | ||
| * Similar to `Partial<T>`, but allows excluding some keys from being made optional. | ||
| * | ||
| * Creates a new type from `T` where: | ||
| * - Keys **included** in the union `I` remain **required** (if they are). | ||
| * - Keys **not included** in `I` become optional **including their value types**, | ||
| * meaning the property can be omitted **or** assigned `undefined`. | ||
| * - If `I` is not provided (defaults to `never`), all keys behave like `Partial<T>`, | ||
| * i.e., all keys become optional and values can be `undefined`. | ||
| * | ||
| * This utility is useful when you want partial objects but want to ensure | ||
| * some keys are always present and required. | ||
| * | ||
| * @template T The original object type. | ||
| * @template I A union of keys from `T` that should remain required. Defaults to `never`. | ||
| * | ||
| * @example | ||
| * type User = { | ||
| * id: string; | ||
| * name: string; | ||
| * email: string; | ||
| * }; | ||
| * | ||
| * type WithIdRequired = OptionalLoose<User, 'id'>; | ||
| * // Equivalent to: | ||
| * // { | ||
| * // id: string; | ||
| * // name?: string | undefined; | ||
| * // email?: string | undefined; | ||
| * // } | ||
| * | ||
| * const u1: WithIdRequired = { id: '123' }; // β valid | ||
| * const u2: WithIdRequired = { id: '123', name: undefined }; // β valid | ||
| * | ||
| * type AllPartial = OptionalLoose<User>; | ||
| * // All keys are optional and values can be undefined. | ||
| * // { | ||
| * // id?: string | undefined; | ||
| * // name?: string | undefined; | ||
| * // email?: string | undefined; | ||
| * // } | ||
| * | ||
| * @since 1.0.22 | ||
| */ | ||
| export type OptionalLoose<T, I extends keyof T = never> = Prettify<{ | ||
| [P in keyof T as P extends I ? P : never]: T[P]; | ||
| } & { | ||
| [P in keyof T as P extends I ? never : P]?: T[P]; | ||
| }>; |
@@ -5,2 +5,2 @@ import atomix from './atomix'; | ||
| export { currencies } from './data/currencies'; | ||
| export type { Objects, DeepReadonly, Prettify, Brand, LooseToStrict, RequiredStrict, Optional, Mime, FileExtension, RRType, TracerouteHop, PortCheckOptions, IPGeolocation, JSONObject, Stringified, NonEmptyArray, AccessPermissions, PathAccessPermissions, AccessOptions, DiscoverHostsOptions, StringPaddingOptions, Serializable, RandomOptions, BaseQueueTask, TasksQueueOptions, AddTasksBaseOptions, EventHandler, AddHandlerOptions, InputSanitizationOptions, FieldRuleMap, SanitizedResult, SanitizationViolation, } from './docs/docs'; | ||
| export type { Objects, DeepReadonly, Prettify, Brand, LooseToStrict, RequiredStrict, Optional, OptionalLoose, Mime, FileExtension, RRType, TracerouteHop, PortCheckOptions, IPGeolocation, JSONObject, Stringified, NonEmptyArray, AccessPermissions, PathAccessPermissions, AccessOptions, DiscoverHostsOptions, StringPaddingOptions, Serializable, RandomOptions, BaseQueueTask, TasksQueueOptions, AddTasksBaseOptions, EventHandler, AddHandlerOptions, InputSanitizationOptions, FieldRuleMap, SanitizedResult, SanitizationViolation, } from './docs/docs'; |
+1
-1
| { | ||
| "name": "@nasriya/atomix", | ||
| "version": "1.0.21", | ||
| "version": "1.0.22", | ||
| "description": "Composable helper functions for building reliable systems", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
632924
0.31%16386
0.34%