tutils
TypeScript utilities.
Install
yarn add @flex-development/tutils
GitHub Package Registry
To install from the GitHub Package Registry, setup a .npmrc
or .yarnrc.yml
file to authenticate with the registry. A Personal Access Token with at least
the read:packages
scope is required.
.npmrc
//npm.pkg.github.com/:_authToken=${GH_PAT}
@flex-development:registry=https://npm.pkg.github.com/
.yarnrc.yml
npmRegistries:
//npm.pkg.github.com:
npmAlwaysAuth: true
npmAuthToken: ${GH_PAT}
npmScopes:
flex-development:
npmRegistryServer: https://npm.pkg.github.com
Git
For details on requesting a specific branch, commit, or tag, see npm-install or Git - Protocols | Yarn.
NPM
npm i flex-development/tutils
Yarn
yarn add @flex-development/tutils@flex-development/tutils
Usage
import type {
NullishNumber,
NullishString,
OrNull,
Path
} from '@flex-development/tutils'
/**
* Object representing a `User` entity **(from the database)**.
*
* **Does not include any [virtual fields][1]**.
*
* [1]: https://sequelize.org/v7/manual/getters-setters-virtuals#virtual-fields
*/
interface IUserRaw {
created_at: number
email: Lowercase<string>
id: number
name: { first: NullishString; last: NullishString }
updated_at: NullishNumber
}
/** {@link IUserRaw} attributes. */
type UserRawAttribute = Path<IUserRaw> // 'created_at' | 'email' | 'id' | 'name' | 'name.first' | 'name.last' | 'updated_at'
export { type IUserRaw as default, type UserRawAttribute }
Exports
- Enums:
src/enums
- Type Definitions:
src/types
- Type Guards:
src/guards