diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 0000000..a387734
--- /dev/null
+++ b/.github/workflows/publish.yml
@@ -0,0 +1,28 @@
+name: Publish
+on:
+ release:
+ types: [published]
+ workflow_dispatch:
+concurrency:
+ group: publish
+ cancel-in-progress: true
+permissions: write-all
+jobs:
+ publish-docs:
+ environment:
+ name: github-pages
+ url: ${{ steps.deploy-pages.outputs.page_url }}
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-node@v3
+ with:
+ cache: npm
+ - run: npm ci
+ - uses: actions/configure-pages@v3
+ - run: npm run build:docs
+ - uses: actions/upload-pages-artifact@v1
+ with:
+ path: docs/dist
+ - id: deploy-pages
+ uses: actions/deploy-pages@v2
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0636138..246c898 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,22 +1,22 @@
name: Test
on:
push:
- branches: [$default-branch]
+ branches: 'dev'
paths:
- src/**
- test/**
- - "*.js"
- - "*.ts"
- - "*.json"
+ - '*.js'
+ - '*.ts'
+ - '*.json'
- .github/workflows/test.yml
pull_request:
- branches: [$default-branch]
+ branches: 'dev'
paths:
- src/**
- test/**
- - "*.js"
- - "*.ts"
- - "*.json"
+ - '*.js'
+ - '*.ts'
+ - '*.json'
- .github/workflows/test.yml
concurrency:
group: test-${{ github.ref }}
@@ -25,7 +25,7 @@ jobs:
test:
strategy:
matrix:
- node-version: ["16", "18", "20"]
+ node-version: ['16', '18', '20']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
diff --git a/.gitignore b/.gitignore
index dcaddcf..6198d8c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+docs/dist
node_modules/
.cache
.rpt2_cache
diff --git a/package-lock.json b/package-lock.json
index 9325d59..8b0bcb5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -20,6 +20,7 @@
"rollup": "^3.22.0",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-esbuild": "^5.0.0",
+ "typedoc": "^0.24.7",
"typescript": "^5.0.4",
"vitest": "^0.31.1"
},
@@ -1189,6 +1190,12 @@
"node": ">=0.10.0"
}
},
+ "node_modules/ansi-sequence-parser": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.0.tgz",
+ "integrity": "sha512-lEm8mt52to2fT8GhciPCGeCXACSz2UwIN4X2e2LJSnZ5uAbn2/dsYdOmUXq0AtWS5cpAupysIneExOgH0Vd2TQ==",
+ "dev": true
+ },
"node_modules/ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
@@ -4530,6 +4537,12 @@
"node": ">=10"
}
},
+ "node_modules/lunr": {
+ "version": "2.3.9",
+ "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz",
+ "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==",
+ "dev": true
+ },
"node_modules/magic-string": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz",
@@ -4584,6 +4597,18 @@
"node": ">=8"
}
},
+ "node_modules/marked": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz",
+ "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==",
+ "dev": true,
+ "bin": {
+ "marked": "bin/marked.js"
+ },
+ "engines": {
+ "node": ">= 12"
+ }
+ },
"node_modules/md5-hex": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz",
@@ -6401,6 +6426,18 @@
"node": ">=8"
}
},
+ "node_modules/shiki": {
+ "version": "0.14.2",
+ "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.2.tgz",
+ "integrity": "sha512-ltSZlSLOuSY0M0Y75KA+ieRaZ0Trf5Wl3gutE7jzLuIcWxLp5i/uEnLoQWNvgKXQ5OMpGkJnVMRLAuzjc0LJ2A==",
+ "dev": true,
+ "dependencies": {
+ "ansi-sequence-parser": "^1.1.0",
+ "jsonc-parser": "^3.2.0",
+ "vscode-oniguruma": "^1.7.0",
+ "vscode-textmate": "^8.0.0"
+ }
+ },
"node_modules/siginfo": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",
@@ -6809,6 +6846,51 @@
"is-typedarray": "^1.0.0"
}
},
+ "node_modules/typedoc": {
+ "version": "0.24.7",
+ "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.24.7.tgz",
+ "integrity": "sha512-zzfKDFIZADA+XRIp2rMzLe9xZ6pt12yQOhCr7cD7/PBTjhPmMyMvGrkZ2lPNJitg3Hj1SeiYFNzCsSDrlpxpKw==",
+ "dev": true,
+ "dependencies": {
+ "lunr": "^2.3.9",
+ "marked": "^4.3.0",
+ "minimatch": "^9.0.0",
+ "shiki": "^0.14.1"
+ },
+ "bin": {
+ "typedoc": "bin/typedoc"
+ },
+ "engines": {
+ "node": ">= 14.14"
+ },
+ "peerDependencies": {
+ "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x"
+ }
+ },
+ "node_modules/typedoc/node_modules/brace-expansion": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "dev": true,
+ "dependencies": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "node_modules/typedoc/node_modules/minimatch": {
+ "version": "9.0.1",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.1.tgz",
+ "integrity": "sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==",
+ "dev": true,
+ "dependencies": {
+ "brace-expansion": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=16 || 14 >=14.17"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
"node_modules/typescript": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz",
@@ -7151,6 +7233,18 @@
}
}
},
+ "node_modules/vscode-oniguruma": {
+ "version": "1.7.0",
+ "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz",
+ "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==",
+ "dev": true
+ },
+ "node_modules/vscode-textmate": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz",
+ "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==",
+ "dev": true
+ },
"node_modules/well-known-symbols": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz",
@@ -8073,6 +8167,12 @@
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
"dev": true
},
+ "ansi-sequence-parser": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.0.tgz",
+ "integrity": "sha512-lEm8mt52to2fT8GhciPCGeCXACSz2UwIN4X2e2LJSnZ5uAbn2/dsYdOmUXq0AtWS5cpAupysIneExOgH0Vd2TQ==",
+ "dev": true
+ },
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
@@ -10558,6 +10658,12 @@
"yallist": "^4.0.0"
}
},
+ "lunr": {
+ "version": "2.3.9",
+ "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz",
+ "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==",
+ "dev": true
+ },
"magic-string": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.0.tgz",
@@ -10599,6 +10705,12 @@
"integrity": "sha512-glc9y00wgtwcDmp7GaE/0b0OnxpNJsVf3ael/An6Fe2Q51LLwN1er6sdomLRzz5h0+yMpiYLhWYF5R7HeqVd4g==",
"dev": true
},
+ "marked": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz",
+ "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==",
+ "dev": true
+ },
"md5-hex": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/md5-hex/-/md5-hex-3.0.1.tgz",
@@ -11889,6 +12001,18 @@
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true
},
+ "shiki": {
+ "version": "0.14.2",
+ "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.2.tgz",
+ "integrity": "sha512-ltSZlSLOuSY0M0Y75KA+ieRaZ0Trf5Wl3gutE7jzLuIcWxLp5i/uEnLoQWNvgKXQ5OMpGkJnVMRLAuzjc0LJ2A==",
+ "dev": true,
+ "requires": {
+ "ansi-sequence-parser": "^1.1.0",
+ "jsonc-parser": "^3.2.0",
+ "vscode-oniguruma": "^1.7.0",
+ "vscode-textmate": "^8.0.0"
+ }
+ },
"siginfo": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",
@@ -12202,6 +12326,38 @@
"is-typedarray": "^1.0.0"
}
},
+ "typedoc": {
+ "version": "0.24.7",
+ "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.24.7.tgz",
+ "integrity": "sha512-zzfKDFIZADA+XRIp2rMzLe9xZ6pt12yQOhCr7cD7/PBTjhPmMyMvGrkZ2lPNJitg3Hj1SeiYFNzCsSDrlpxpKw==",
+ "dev": true,
+ "requires": {
+ "lunr": "^2.3.9",
+ "marked": "^4.3.0",
+ "minimatch": "^9.0.0",
+ "shiki": "^0.14.1"
+ },
+ "dependencies": {
+ "brace-expansion": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "dev": true,
+ "requires": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "minimatch": {
+ "version": "9.0.1",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.1.tgz",
+ "integrity": "sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "^2.0.1"
+ }
+ }
+ }
+ },
"typescript": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz",
@@ -12407,6 +12563,18 @@
"why-is-node-running": "^2.2.2"
}
},
+ "vscode-oniguruma": {
+ "version": "1.7.0",
+ "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz",
+ "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==",
+ "dev": true
+ },
+ "vscode-textmate": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz",
+ "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==",
+ "dev": true
+ },
"well-known-symbols": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz",
diff --git a/package.json b/package.json
index 6b786a4..260ad66 100644
--- a/package.json
+++ b/package.json
@@ -29,6 +29,7 @@
"test": "vitest run",
"lint": "tsc --noEmit && eslint ./src --ext .ts",
"build": "rollup -c ./rollup.config.js",
+ "build:docs": "typedoc",
"release": "npm run lint && del dist && npm run build && np"
},
"repository": {
@@ -76,7 +77,8 @@
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-esbuild": "^5.0.0",
"typescript": "^5.0.4",
- "vitest": "^0.31.1"
+ "vitest": "^0.31.1",
+ "typedoc": "^0.24.7"
},
"ava": {
"extensions": {
diff --git a/src/index.ts b/src/index.ts
index d2044e1..60e297d 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -359,21 +359,65 @@ export function isPrimitive(
*/
export const isNullOrUndefined = isOneOf(isNull, isUndefined)
+/**
+ * A factory function that creates a function to check if the payload is one of the given types.
+ * @example
+ * import { isOneOf, isNull, isUndefined } from 'is-what'
+ *
+ * const isNullOrUndefined = isOneOf(isNull, isUndefined)
+ *
+ * isNullOrUndefined(null) // true
+ * isNullOrUndefined(undefined) // true
+ * isNullOrUndefined(123) // false
+ */
export function isOneOf(
a: TypeGuard,
b: TypeGuard
): TypeGuard
+/**
+ * A factory function that creates a function to check if the payload is one of the given types.
+ * @example
+ * import { isOneOf, isNull, isUndefined } from 'is-what'
+ *
+ * const isNullOrUndefined = isOneOf(isNull, isUndefined)
+ *
+ * isNullOrUndefined(null) // true
+ * isNullOrUndefined(undefined) // true
+ * isNullOrUndefined(123) // false
+ */
export function isOneOf(
a: TypeGuard,
b: TypeGuard,
c: TypeGuard
): TypeGuard
+/**
+ * A factory function that creates a function to check if the payload is one of the given types.
+ * @example
+ * import { isOneOf, isNull, isUndefined } from 'is-what'
+ *
+ * const isNullOrUndefined = isOneOf(isNull, isUndefined)
+ *
+ * isNullOrUndefined(null) // true
+ * isNullOrUndefined(undefined) // true
+ * isNullOrUndefined(123) // false
+ */
export function isOneOf(
a: TypeGuard,
b: TypeGuard,
c: TypeGuard,
d: TypeGuard
): TypeGuard
+/**
+ * A factory function that creates a function to check if the payload is one of the given types.
+ * @example
+ * import { isOneOf, isNull, isUndefined } from 'is-what'
+ *
+ * const isNullOrUndefined = isOneOf(isNull, isUndefined)
+ *
+ * isNullOrUndefined(null) // true
+ * isNullOrUndefined(undefined) // true
+ * isNullOrUndefined(123) // false
+ */
export function isOneOf(
a: TypeGuard,
b: TypeGuard,
@@ -381,6 +425,17 @@ export function isOneOf,
e: TypeGuard
): TypeGuard
+/**
+ * A factory function that creates a function to check if the payload is one of the given types.
+ * @example
+ * import { isOneOf, isNull, isUndefined } from 'is-what'
+ *
+ * const isNullOrUndefined = isOneOf(isNull, isUndefined)
+ *
+ * isNullOrUndefined(null) // true
+ * isNullOrUndefined(undefined) // true
+ * isNullOrUndefined(123) // false
+ */
export function isOneOf(
a: AnyFunction,
b: AnyFunction,
diff --git a/tsconfig.json b/tsconfig.json
index 959cd90..620dd4d 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -17,5 +17,10 @@
"target": "es2019",
"useDefineForClassFields": true
},
- "include": ["src/**/*", "test/**/*"]
+ "include": ["src/**/*", "test/**/*"],
+ "typedocOptions": {
+ "entryPoints": ["src/index.ts"],
+ "out": "docs/dist",
+ "skipErrorChecking": true
+ }
}