From 52445125750d6ee29856224c9c14cba6d399554c Mon Sep 17 00:00:00 2001 From: Adam Laycock Date: Thu, 23 Mar 2023 16:00:34 +0000 Subject: [PATCH] fix: build index from names in comment and support excluding --- Readme.md | 12 ++ package-lock.json | 222 ++++++++++++++++++++++++++++++ package.json | 1 + scripts/build.cjs | 30 +++- src/classes/bit-mask.ts | 2 + src/classes/logger.ts | 2 + src/functions/address-object.ts | 2 + src/functions/array-move.ts | 2 + src/functions/array-selectors.ts | 2 + src/functions/async-for-each.ts | 2 + src/functions/async-map.ts | 2 + src/functions/cache-for.ts | 2 + src/functions/clamp.ts | 2 + src/functions/create-map.ts | 2 + src/functions/css.ts | 2 + src/functions/dates.ts | 2 + src/functions/deep-includes.ts | 2 + src/functions/defaults.ts | 2 + src/functions/diff-array.ts | 2 + src/functions/diff-object.ts | 2 + src/functions/grouped-by.ts | 2 + src/functions/if-fn.ts | 2 + src/functions/increment.ts | 2 + src/functions/indexed-by.ts | 2 + src/functions/invariant.ts | 2 + src/functions/is-env.ts | 2 + src/functions/keys.ts | 2 + src/functions/map-property.ts | 2 + src/functions/network.ts | 2 + src/functions/nl2br.ts | 2 + src/functions/package.ts | 2 + src/functions/parameterize.ts | 2 + src/functions/pick.ts | 2 + src/functions/range-as-string.ts | 2 + src/functions/reduce.ts | 2 + src/functions/replace-property.ts | 2 + src/functions/selectors.ts | 2 + src/functions/time.ts | 2 + src/functions/times.ts | 2 + src/functions/unique.ts | 2 + src/functions/value-or.ts | 2 + src/functions/wait-for.ts | 2 + 42 files changed, 339 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 5c4ee2a..f50e4b5 100644 --- a/Readme.md +++ b/Readme.md @@ -19,3 +19,15 @@ yarn add @arcath/utils ## More A full list of functions and classes can be found at https://utils.arcath.net + +## Developing + +Each function/class should have its own file with a spec file along side. +Similar functions can be in the same file e.g. `increment` and `decrement`. + +The index is generated using a comment at the bottom of the file to define the +exports. For example + +```js +// {increment, decrement} +``` diff --git a/package-lock.json b/package-lock.json index 664c7ba..9890375 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "kcd-scripts": "^13.0.0", "prettier": "^2.8.6", "ts-jest": "^29.0.5", + "ts-node": "^10.9.1", "typedoc": "^0.23.28", "typescript": "^5.0.2" } @@ -1926,6 +1927,28 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.3.0.tgz", @@ -2822,6 +2845,30 @@ "node": ">= 10" } }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", + "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==", + "dev": true + }, "node_modules/@types/aria-query": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.1.tgz", @@ -3559,6 +3606,12 @@ "node": ">= 8" } }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -4745,6 +4798,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -5006,6 +5065,15 @@ "node": ">=8" } }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/diff-sequences": { "version": "29.4.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", @@ -12732,6 +12800,49 @@ "node": ">=10" } }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, "node_modules/tsconfig-paths": { "version": "3.14.2", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", @@ -13175,6 +13286,12 @@ "node": ">=0.10.0" } }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/v8-to-istanbul": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.0.1.tgz", @@ -13588,6 +13705,15 @@ "node": ">=8" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -14928,6 +15054,27 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, + "@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "dependencies": { + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + } + } + }, "@eslint-community/eslint-utils": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.3.0.tgz", @@ -15628,6 +15775,30 @@ "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", "dev": true }, + "@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "@tsconfig/node16": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", + "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==", + "dev": true + }, "@types/aria-query": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.1.tgz", @@ -16191,6 +16362,12 @@ "picomatch": "^2.0.4" } }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -17087,6 +17264,12 @@ "p-map": "^3.0.0" } }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -17288,6 +17471,12 @@ "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", "dev": true }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, "diff-sequences": { "version": "29.4.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", @@ -23034,6 +23223,27 @@ } } }, + "ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "requires": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + } + }, "tsconfig-paths": { "version": "3.14.2", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", @@ -23354,6 +23564,12 @@ "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", "dev": true }, + "v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "v8-to-istanbul": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.0.1.tgz", @@ -23659,6 +23875,12 @@ "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + }, "yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 9dbfca2..20a0dd5 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "kcd-scripts": "^13.0.0", "prettier": "^2.8.6", "ts-jest": "^29.0.5", + "ts-node": "^10.9.1", "typedoc": "^0.23.28", "typescript": "^5.0.2" }, diff --git a/scripts/build.cjs b/scripts/build.cjs index 13006a9..737f981 100644 --- a/scripts/build.cjs +++ b/scripts/build.cjs @@ -14,7 +14,21 @@ fs.readdir(FUNCTIONS, (err, files) => { return } - lines.push(`export * from './functions/${file.replace('.ts', '')}'`) + const buff = fs.readFileSync(path.join(FUNCTIONS, file)) + + const line = buff.toString().split('\n').slice(-2, -1)[0] + + if (line.match(`// {.*?}`)) { + lines.push( + `export {${ + line.match(`// {(.*?)}`)[1] + }} from './functions/${file.replace('.ts', '')}'` + ) + } else { + if (!line.match(`// exclude`)) { + throw new Error(`functions/${file} has no exports`) + } + } }) fs.readdir(CLASSES, (err, files) => { @@ -23,7 +37,19 @@ fs.readdir(FUNCTIONS, (err, files) => { return } - lines.push(`export * from './classes/${file.replace('.ts', '')}'`) + const buff = fs.readFileSync(path.join(CLASSES, file)) + + const line = buff.toString().split('\n').slice(-2, -1)[0] + + if (line.match(`// {.*?}`)) { + lines.push( + `export {${ + line.match(`// {(.*?)}`)[1] + }} from './classes/${file.replace('.ts', '')}'` + ) + } else { + throw new Error(`classes/${file} has no exports`) + } }) fs.writeFile(INDEX, lines.join(`\r\n`), err => {}) diff --git a/src/classes/bit-mask.ts b/src/classes/bit-mask.ts index edacf2c..722a41e 100644 --- a/src/classes/bit-mask.ts +++ b/src/classes/bit-mask.ts @@ -91,3 +91,5 @@ export class BitMask { }) } } + +// {BitMask} diff --git a/src/classes/logger.ts b/src/classes/logger.ts index 6068f5b..d12c62c 100644 --- a/src/classes/logger.ts +++ b/src/classes/logger.ts @@ -72,3 +72,5 @@ export class Logger { ) } } + +// {Logger, LoggerOptions} diff --git a/src/functions/address-object.ts b/src/functions/address-object.ts index 21288ba..61b7620 100644 --- a/src/functions/address-object.ts +++ b/src/functions/address-object.ts @@ -64,3 +64,5 @@ export const testObjectAddress = ( {currentObject: object, result: true} ).result } + +// {addressObject, testObjectAddress} diff --git a/src/functions/array-move.ts b/src/functions/array-move.ts index 5ea47e2..a4ebff3 100644 --- a/src/functions/array-move.ts +++ b/src/functions/array-move.ts @@ -23,3 +23,5 @@ export const arrayMove = ( return array as T[] } + +// {arrayMove} diff --git a/src/functions/array-selectors.ts b/src/functions/array-selectors.ts index 3bd1cfd..297b1a8 100644 --- a/src/functions/array-selectors.ts +++ b/src/functions/array-selectors.ts @@ -9,3 +9,5 @@ export const randomEntry = (array: Entry[]): Entry => { return array[(array.length * Math.random()) | 0] } + +// {randomEntry} diff --git a/src/functions/async-for-each.ts b/src/functions/async-for-each.ts index 48e7319..b97418a 100644 --- a/src/functions/async-for-each.ts +++ b/src/functions/async-for-each.ts @@ -14,3 +14,5 @@ export const asyncForEach = async ( await Promise.all(promises) } + +// {asyncForEach} diff --git a/src/functions/async-map.ts b/src/functions/async-map.ts index 8f4bf53..5a5e465 100644 --- a/src/functions/async-map.ts +++ b/src/functions/async-map.ts @@ -10,3 +10,5 @@ export const asyncMap = async ( ): Promise => { return Promise.all(list.map(executor)) } + +// {asyncMap} diff --git a/src/functions/cache-for.ts b/src/functions/cache-for.ts index af912c0..2182509 100644 --- a/src/functions/cache-for.ts +++ b/src/functions/cache-for.ts @@ -104,3 +104,5 @@ export const cacheFor = async ( return cache[key] } + +// {cacheFor, cacheForSync, expireKey, cacheKey, cacheKeyExists, resetCache, CacheForOptions} diff --git a/src/functions/clamp.ts b/src/functions/clamp.ts index 0d94b31..24689f9 100644 --- a/src/functions/clamp.ts +++ b/src/functions/clamp.ts @@ -1,2 +1,4 @@ export const clamp = (num: number, min: number, max: number) => Math.min(Math.max(num, min), max) + +// {clamp} diff --git a/src/functions/create-map.ts b/src/functions/create-map.ts index 4e1c528..1f77f67 100644 --- a/src/functions/create-map.ts +++ b/src/functions/create-map.ts @@ -153,3 +153,5 @@ export const createMap = ( minY } } + +// {createMap, Map} diff --git a/src/functions/css.ts b/src/functions/css.ts index 9abc0bc..7e67af6 100644 --- a/src/functions/css.ts +++ b/src/functions/css.ts @@ -45,3 +45,5 @@ export const numberToRem = asUnit('rem') export const numberToVh = asUnit('vh') /** Conver a number to vw */ export const numberToVw = asUnit('vw') + +// {pxToNumber, emToNumber, remToNumber, vhToNumber, vwToNumber, numberToPx, numberToEm, numberToRem, numberToVh, numberToVw} diff --git a/src/functions/dates.ts b/src/functions/dates.ts index 350c065..e292363 100644 --- a/src/functions/dates.ts +++ b/src/functions/dates.ts @@ -44,3 +44,5 @@ export const lastModifiedHeaderDate = dateOrStringFunction(date => { .toString() .padStart(2, '0')} GMT` }) + +// {lastModifiedHeaderDate} diff --git a/src/functions/deep-includes.ts b/src/functions/deep-includes.ts index 8f00249..66df799 100644 --- a/src/functions/deep-includes.ts +++ b/src/functions/deep-includes.ts @@ -18,3 +18,5 @@ export const deepIncludesArray = ( }) }) } + +// {deepIncludesArray} diff --git a/src/functions/defaults.ts b/src/functions/defaults.ts index 8092e1a..262970b 100644 --- a/src/functions/defaults.ts +++ b/src/functions/defaults.ts @@ -29,3 +29,5 @@ export const defaults = ( return result } + +// {defaults} diff --git a/src/functions/diff-array.ts b/src/functions/diff-array.ts index e776527..ae3086e 100644 --- a/src/functions/diff-array.ts +++ b/src/functions/diff-array.ts @@ -30,3 +30,5 @@ export const diffArray = ( common } } + +// {diffArray} diff --git a/src/functions/diff-object.ts b/src/functions/diff-object.ts index 56b7086..f53bd21 100644 --- a/src/functions/diff-object.ts +++ b/src/functions/diff-object.ts @@ -49,3 +49,5 @@ export const diffObject = ( return result } + +// {diffObject, DiffObjectResult} diff --git a/src/functions/grouped-by.ts b/src/functions/grouped-by.ts index 71f31e3..6ac2a14 100644 --- a/src/functions/grouped-by.ts +++ b/src/functions/grouped-by.ts @@ -24,3 +24,5 @@ export const groupedBy = ( return groups }, {}) } + +// {groupedBy, GroupedArray} diff --git a/src/functions/if-fn.ts b/src/functions/if-fn.ts index 43e07d4..4442fae 100644 --- a/src/functions/if-fn.ts +++ b/src/functions/if-fn.ts @@ -22,3 +22,5 @@ export const ifFn = (fn: (argument: Argument) => boolean) => { return fn(argument) ? truthy : falsy } } + +// {ifFn} diff --git a/src/functions/increment.ts b/src/functions/increment.ts index 5b3e8fe..c9c38d9 100644 --- a/src/functions/increment.ts +++ b/src/functions/increment.ts @@ -92,3 +92,5 @@ export const decrement = ( return counter } } + +// {increment, IncrementFunction, IncrementOptions, decrement} diff --git a/src/functions/indexed-by.ts b/src/functions/indexed-by.ts index 0b93a28..4026674 100644 --- a/src/functions/indexed-by.ts +++ b/src/functions/indexed-by.ts @@ -38,3 +38,5 @@ export const indexedBy = ( return indexedArray }, {}) } + +// {indexedBy, IndexedArray, IndexedByOptions} diff --git a/src/functions/invariant.ts b/src/functions/invariant.ts index c106969..e21c7ca 100644 --- a/src/functions/invariant.ts +++ b/src/functions/invariant.ts @@ -45,3 +45,5 @@ export function invariant( const errorMessage = provided ? `${prefix}: ${provided}` : prefix throw new Error(errorMessage) } + +// {invariant, InvariantOptions} diff --git a/src/functions/is-env.ts b/src/functions/is-env.ts index 01e5420..ccf6380 100644 --- a/src/functions/is-env.ts +++ b/src/functions/is-env.ts @@ -6,3 +6,5 @@ export const isEnv = (env: string) => process.env.NODE_ENV === env export const isProduction = isEnv('production') export const isDev = isEnv('development') export const isTest = isEnv('test') + +// {isEnv, isProduction, isDev, isTest} diff --git a/src/functions/keys.ts b/src/functions/keys.ts index 0b0e5c4..a220c68 100644 --- a/src/functions/keys.ts +++ b/src/functions/keys.ts @@ -24,3 +24,5 @@ export const keyValue = ( return {key, value: object[key]} }) } + +// {keys, keyValue} diff --git a/src/functions/map-property.ts b/src/functions/map-property.ts index 58f6287..5932473 100644 --- a/src/functions/map-property.ts +++ b/src/functions/map-property.ts @@ -10,3 +10,5 @@ export const mapProperty = ( ): T[K][] => { return array.map(element => element[property]) } + +// {mapProperty} diff --git a/src/functions/network.ts b/src/functions/network.ts index dd5ecb6..ced014d 100644 --- a/src/functions/network.ts +++ b/src/functions/network.ts @@ -104,3 +104,5 @@ export const parseCDIR = (cdir: string): CIDRObject => { size } } + +// {parseCDIR, CIDRObject} diff --git a/src/functions/nl2br.ts b/src/functions/nl2br.ts index 4dbdb9f..2627434 100644 --- a/src/functions/nl2br.ts +++ b/src/functions/nl2br.ts @@ -6,3 +6,5 @@ export const nl2br = (string: string) => { return string.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1
$2') } + +// {nl2br} diff --git a/src/functions/package.ts b/src/functions/package.ts index 8483028..690fc56 100644 --- a/src/functions/package.ts +++ b/src/functions/package.ts @@ -113,3 +113,5 @@ export const getPackage = (options?: Partial): Package => { ifScript: ifFn((script: string) => hasScript(pkg, script)) } } + +// exclude diff --git a/src/functions/parameterize.ts b/src/functions/parameterize.ts index c5ab461..695f871 100644 --- a/src/functions/parameterize.ts +++ b/src/functions/parameterize.ts @@ -11,3 +11,5 @@ export const parameterize = (slug: string): string => { .replace(/[^a-zA-Z0-9 -]/g, '') .replace(/\s/g, '-') } + +// {parameterize} diff --git a/src/functions/pick.ts b/src/functions/pick.ts index 54121b4..3ce6824 100644 --- a/src/functions/pick.ts +++ b/src/functions/pick.ts @@ -49,3 +49,5 @@ export const omit = < return obj }, {}) } + +// {pick, omit} diff --git a/src/functions/range-as-string.ts b/src/functions/range-as-string.ts index d7caa3d..e539bb3 100644 --- a/src/functions/range-as-string.ts +++ b/src/functions/range-as-string.ts @@ -48,3 +48,5 @@ export const rangeAsString = (integers: number[]): string[] => { return `${range[0]}-${range[1]}` }) } + +// {rangeAsString, rangeAsArray} diff --git a/src/functions/reduce.ts b/src/functions/reduce.ts index 55cb610..3a0f103 100644 --- a/src/functions/reduce.ts +++ b/src/functions/reduce.ts @@ -62,3 +62,5 @@ export const reduceFalsy = ( ) => { return reducio(array, (v, i) => !check(v, i), {initial: true}) } + +// {reduceTruthy, reduceFalsy, RedicioOptions, reducio} diff --git a/src/functions/replace-property.ts b/src/functions/replace-property.ts index 0bda3e5..46c69f2 100644 --- a/src/functions/replace-property.ts +++ b/src/functions/replace-property.ts @@ -19,3 +19,5 @@ export const replaceProperty = ( return newObject } + +// {replaceProperty} diff --git a/src/functions/selectors.ts b/src/functions/selectors.ts index f21f62f..1cde9f6 100644 --- a/src/functions/selectors.ts +++ b/src/functions/selectors.ts @@ -31,3 +31,5 @@ export const propIsNot = ( return item[prop] !== value }) } + +// {propIs, propIsNot} diff --git a/src/functions/time.ts b/src/functions/time.ts index fd6d2e1..19b7a7a 100644 --- a/src/functions/time.ts +++ b/src/functions/time.ts @@ -62,3 +62,5 @@ export const hoursInSeconds = chain( multiplyBy(MINUTE_IN_SECONDS) ) export const hoursInMinutes = multiplyBy(HOUR_IN_MINUTES) + +// {msAsSeconds, msAsMinutes, msAsHour, secondsInMs, secondsAsMinutes, secondsAsHours, minutesInMs, minutesInSeconds, minutesAsHours, hoursInMs, hoursInMinutes, hoursInSeconds, SECOND_IN_MS, MINUTE_IN_SECONDS, MINUTE_IN_MS, HOUR_IN_MINUTES, HOUR_IN_SECONDS, HOUR_IN_MS} diff --git a/src/functions/times.ts b/src/functions/times.ts index 436450f..a734c8b 100644 --- a/src/functions/times.ts +++ b/src/functions/times.ts @@ -33,3 +33,5 @@ export const asyncTimes = async ( return asyncMap(numbers, cb) } + +// {times, asyncTimes} diff --git a/src/functions/unique.ts b/src/functions/unique.ts index eb4fdf9..2f46e64 100644 --- a/src/functions/unique.ts +++ b/src/functions/unique.ts @@ -14,3 +14,5 @@ export const unique = (array: T[]): T[] => { return result } + +// {unique} diff --git a/src/functions/value-or.ts b/src/functions/value-or.ts index 89390e5..2901d7d 100644 --- a/src/functions/value-or.ts +++ b/src/functions/value-or.ts @@ -9,3 +9,5 @@ export const valueOr = (value: T | undefined, or: T) => { return or } + +// {valueOr} diff --git a/src/functions/wait-for.ts b/src/functions/wait-for.ts index 1599556..894f366 100644 --- a/src/functions/wait-for.ts +++ b/src/functions/wait-for.ts @@ -17,3 +17,5 @@ export const waitFor = async ( return [null, e] }) } + +// {waitFor, WaitForResult}