feat: adding pure annotation for better tree shaking

This commit is contained in:
Jacob Nguyen
2023-02-17 15:40:32 -06:00
parent ce9a0831a6
commit d20d01524b
3 changed files with 4 additions and 2 deletions

View File

@@ -22,6 +22,7 @@ export function single<T extends NotFunction>(cb: T): () => T;
*/
export function single<T extends () => unknown>(cb: T): T;
/**
* @__PURE__
* Please note that on intellij, the deprecation is for all signatures, which is unintended behavior (and
* very annoying).
* For future versions, ensure that single is being passed as a **callback!!**
@@ -39,6 +40,7 @@ export function single<T>(cb: T) {
export function transient<T extends NotFunction>(cb: T): () => () => T;
export function transient<T extends () => () => unknown>(cb: T): T;
/**
* @__PURE__
* Following iti's singleton and transient implementation,
* use transient if you want a new dependency every time your container getter is called
* @param cb
@@ -49,6 +51,7 @@ export function transient<T>(cb: (() => () => T) | T) {
}
/**
* @__PURE__
* @deprecated
* @param value
* Please use the transient function instead

View File

@@ -5,6 +5,7 @@ import { Err, Ok } from 'ts-results-es';
* A function that returns whatever value is provided.
* Warning: this evaluates { @param value }. It does not defer a value.
* @param value
* @__PURE__
*/
// prettier-ignore
export const _const = <T>(value: T) => () => value;

View File

@@ -13,7 +13,6 @@ export default defineConfig([
target: 'node16',
tsconfig: './tsconfig-esm.json',
outDir: './dist/esm',
external: ['discord.js'],
treeshake: true,
outExtension() {
return {
@@ -25,7 +24,6 @@ export default defineConfig([
{
format: 'cjs',
splitting: false,
external: ['discord.js'],
target: 'node16',
tsconfig: './tsconfig-cjs.json',
outDir: './dist/cjs',