{"_id":"@bestcodetools/generic-types","name":"@bestcodetools/generic-types","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@bestcodetools/generic-types","version":"0.0.1","main":"","scripts":{"build":"tsc","postbuild":"npm pack"},"publishConfig":{"access":"public"},"types":"dist/index.d.ts","type":"module","keywords":[],"author":{"name":"BestCodeTools"},"license":"ISC","description":"Welcome to the Generic Types library! This library provides a set of generic types designed to help you work with TypeScript efficiently. Below you'll find a list of exported types, their purposes, and usage examples.","devDependencies":{"@types/node":"^22.13.4","typescript":"^5.7.3"},"_id":"@bestcodetools/generic-types@0.0.1","gitHead":"83e9161a080fb12e8aa273a76e6cf14eb26029e0","_nodeVersion":"20.18.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-gu1YTKi9abAMWOMDFPy+ipykydCvhBJKCbry/0BtGgNnHcsI79QMWCWO0yMOLOjlga0SXM9kM6JRLYkIj9SnSA==","shasum":"1e405c25530357f57e0433eacdaf636616fb0815","tarball":"https://registry.npmjs.org/@bestcodetools/generic-types/-/generic-types-0.0.1.tgz","fileCount":33,"unpackedSize":10995,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFl6j/EAna3vRFiO7a39/Pew4GNR+qCs5dGe8CUX+svHAiEAl+lFwviob1djyTOObVzQqObOi5+B7aZEwwT3w3+TyBc="}]},"_npmUser":{"name":"kamikai","email":"kamikai@gmail.com"},"directories":{},"maintainers":[{"name":"kamikai","email":"kamikai@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/generic-types_0.0.1_1739826270952_0.8083049373877744"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-17T21:04:30.856Z","0.0.1":"2025-02-17T21:04:31.265Z","modified":"2025-02-17T21:04:31.557Z"},"maintainers":[{"name":"kamikai","email":"kamikai@gmail.com"}],"description":"Welcome to the Generic Types library! This library provides a set of generic types designed to help you work with TypeScript efficiently. Below you'll find a list of exported types, their purposes, and usage examples.","keywords":[],"author":{"name":"BestCodeTools"},"license":"ISC","readme":"# Generic Types Library\n\nWelcome to the Generic Types library! This library provides a set of generic types designed to help you work with TypeScript efficiently. Below you'll find a list of exported types, their purposes, and usage examples.\n\n## Exported Types\n\n### `ArrayElement`\n\n**Purpose**: Extracts the type of elements within an array type. This is useful when you need to work with the individual elements of an array and want to ensure type safety.\n\n**Usage Example**:\n\n```typescript\ntype NumberArray = number[];\ntype NumberElement = ArrayElement<NumberArray>; // number\n\nconst element: NumberElement = 3; // Valid assignment\n```\n\n### `Awaited`\n\n**Purpose**: Unwraps the type of a promise to get the resolved value type. This is useful when working with asynchronous functions to ensure type safety for the resolved values.\n\n**Usage Example**:\n\n```typescript\ntype PromiseNumber = Promise<number>;\ntype ResolvedNumber = Awaited<PromiseNumber>; // number\n\nasync function getNumber(): PromiseNumber {\n  return 42;\n}\n\nconst number: ResolvedNumber = await getNumber(); // Valid assignment\n```\n\n\n### `UnionToIntersection`\n\n**Purpose**: Converts a union type into an intersection type. This is useful when you want to merge multiple types into a single type with all the properties of the original types.\n\n**Usage Example**:\n\n```typescript\ntype A = { a: string };\ntype B = { b: number };\ntype C = { c: boolean };\n\ntype ABC = UnionToIntersection<A | B | C>; // { a: string } & { b: number } & { c: boolean }\n\nconst example: ABC = {\n  a: \"Hello\",\n  b: 42,\n  c: true\n};\n```\n\n### `Mutable`\n\n**Purpose**: Makes all properties of a given type mutable. This is useful when you need to modify properties of an object that are otherwise read-only.\n\n**Usage Example**:\n\n```typescript\ntype ReadonlyObject = {\n  readonly name: string;\n  readonly age: number;\n};\n\ntype MutableObject = Mutable<ReadonlyObject>;\n\nlet person: MutableObject = {\n  name: \"Alice\",\n  age: 30\n};\n\nperson.name = \"Bob\"; // This is allowed because the properties are now mutable.\n```\n\n### `MutableKeys`\n\n**Purpose**: Extracts the keys of a type that are mutable. This can be used to determine which properties of an object can be modified.\n\n**Usage Example**:\n\n```typescript\ntype Sample = {\n  readonly id: number;\n  name: string;\n  age: number;\n};\n\ntype MutableKeysOfSample = MutableKeys<Sample>; // \"name\" | \"age\"\n\nconst mutableKeys: MutableKeysOfSample = \"name\"; // Valid assignment\n```\n\n### `ReadonlyKeys`\n\n**Purpose**: Extracts the keys of a type that are read-only. This is useful for identifying properties that cannot be modified.\n\n**Usage Example**:\n\n```typescript\ntype Sample = {\n  readonly id: number;\n  name: string;\n  age: number;\n};\n\ntype ReadonlyKeysOfSample = ReadonlyKeys<Sample>; // \"id\"\n\nconst readonlyKeys: ReadonlyKeysOfSample = \"id\"; // Valid assignment\n```\n\n## Installation\n\nTo use this library, install it via npm:\n\n```bash\nnpm install @bestcodetools/generic-types\n```\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under ISC License.\n\n---\n\nEnjoy using the Generic Types library!\n","readmeFilename":"readme.md"}