generated from templates/typescript-types
Compare commits
4 Commits
2eea0e09c4
...
a73cd2b923
Author | SHA1 | Date | |
---|---|---|---|
a73cd2b923 | |||
fb45ad6ee5 | |||
2527241e25 | |||
065a29f0cc |
@ -3,9 +3,9 @@ name: Build and publish
|
||||
|
||||
on:
|
||||
workflow_dispatch: { }
|
||||
# push:
|
||||
# branches:
|
||||
# - master
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@templates/typescript-types",
|
||||
"version": "1.0.0",
|
||||
"version": "0.2.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@templates/typescript-types",
|
||||
"version": "1.0.0",
|
||||
"version": "0.2.0",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.1.3"
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@js/types",
|
||||
"version": "0.1.0",
|
||||
"description": "Template project for creating new TypeScript type-definition-only packages",
|
||||
"version": "0.2.0",
|
||||
"description": "Collection of generic TypeScript type definitions for various utility purposes",
|
||||
"main": "src/index.d.ts",
|
||||
"types": "src/index.d.ts",
|
||||
"publishConfig": {
|
||||
@ -9,7 +9,7 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitea.jbrumond.me/js/typescript-types.git"
|
||||
"url": "https://gitea.jbrumond.me/js/types.git"
|
||||
},
|
||||
"author": "James Brumond <https://jbrumond.me>",
|
||||
"license": "ISC",
|
||||
|
21
readme.md
21
readme.md
@ -14,6 +14,7 @@ npm install --save-dev @js/types
|
||||
import {
|
||||
// Various identifier strings
|
||||
HttpURL,
|
||||
HttpURLSchemeless,
|
||||
UUID,
|
||||
SnowflakeID,
|
||||
|
||||
@ -24,6 +25,24 @@ import {
|
||||
// Pino-compatible logger interface
|
||||
Logger,
|
||||
LogFn,
|
||||
} from '@js/types';
|
||||
|
||||
// Function helpers
|
||||
Func,
|
||||
Params,
|
||||
FirstParam,
|
||||
NonFirstParams,
|
||||
WithoutFirstParam,
|
||||
|
||||
// Language / locale
|
||||
Locale,
|
||||
|
||||
// Date / time
|
||||
ISODate,
|
||||
ISOTime,
|
||||
ISOZoneOffset,
|
||||
ISOTimestamp,
|
||||
TimeShort,
|
||||
LocalDateTime,
|
||||
Timezone,
|
||||
} from '@js/types';
|
||||
```
|
||||
|
10
src/functions.d.ts
vendored
Normal file
10
src/functions.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
export type Func<T extends any = any> = (...args: any[]) => T;
|
||||
|
||||
export type Params<T extends Func> = T extends (...args: infer P) => any ? P : never;
|
||||
|
||||
export type FirstParam<T extends Func> = T extends (first: infer F, ...args: any[]) => any ? F : never;
|
||||
|
||||
export type NonFirstParams<T extends Func> = T extends (first: any, ...args: infer P) => any ? P : never;
|
||||
|
||||
export type WithoutFirstParam<T extends Func> = T extends (first: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
6
src/identifiers.d.ts
vendored
6
src/identifiers.d.ts
vendored
@ -1,6 +1,12 @@
|
||||
|
||||
/** An HTTP URL, e.g. `https://example.com/foo?bar=baz` */
|
||||
export type HttpURL = `http://${string}` | `https://${string}`;
|
||||
|
||||
/** An HTTP URL without the scheme specified, e.g. `//example.com/foo?bar=baz` */
|
||||
export type HttpURLSchemeless = `//${string}`;
|
||||
|
||||
/** An RFC 4122 Universally Unique Identifier string */
|
||||
export type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
||||
|
||||
/** A Snowflake unique identifier string */
|
||||
export type SnowflakeID = `${bigint}`;
|
||||
|
3
src/index.d.ts
vendored
3
src/index.d.ts
vendored
@ -1,4 +1,7 @@
|
||||
|
||||
export * from './functions';
|
||||
export * from './http';
|
||||
export * from './identifiers';
|
||||
export * from './locale';
|
||||
export * from './logger';
|
||||
export * from './time';
|
||||
|
3
src/locale.d.ts
vendored
Normal file
3
src/locale.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
/** A combined ISO 639-1 language code and ISO 3166-1 alpha-2 country code, like `en-US` */
|
||||
export type Locale = `${string}-${string}`;
|
21
src/time.d.ts
vendored
Normal file
21
src/time.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
/** A date string, formatted `YYYY-MM-DD` */
|
||||
export type ISODate = `${number}-${number}-${number}`;
|
||||
|
||||
/** A time string, formatted `HH:mm:ss.sss` */
|
||||
export type ISOTime = `${number}:${number}:${number}.${number}`;
|
||||
|
||||
/** */
|
||||
export type ISOZoneOffset = 'Z' | `${'+' | '-' | ''}${number}:${number}`;
|
||||
|
||||
/** */
|
||||
export type ISOTimestamp = `${ISODate}T${ISOTime}${ISOZoneOffset}`;
|
||||
|
||||
/** A time string, formatted `HH:mm` */
|
||||
export type TimeShort = `${number}:${number}`;
|
||||
|
||||
/** A date/time string, formatted `YYYY-MM-DD HH:mm` */
|
||||
export type LocalDateTime = `${ISODate} ${TimeShort}`;
|
||||
|
||||
/** A timezone identifier string, like `America/Los_Angeles` */
|
||||
export type Timezone = `${string}/${string}`;
|
Loading…
x
Reference in New Issue
Block a user