xenopomp-essentials 0.3.2 → 0.3.4-hotfix.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/cli-tools/index.d.mts +60 -0
  2. package/cli-tools/index.d.ts +60 -0
  3. package/cli-tools/index.mjs +1 -0
  4. package/eslint/index.d.mts +39 -0
  5. package/eslint/index.d.ts +39 -0
  6. package/eslint/index.mjs +3 -0
  7. package/index.d.mts +613 -0
  8. package/index.d.ts +613 -0
  9. package/index.mjs +1 -0
  10. package/next/index.d.mts +67 -0
  11. package/next/index.d.ts +67 -0
  12. package/next/index.mjs +11 -0
  13. package/package.json +4 -1
  14. package/.config/.lintstagedrc.json +0 -3
  15. package/.config/build.config.ts +0 -41
  16. package/.config/testing-exclusions/index.ts +0 -2
  17. package/.config/testing-exclusions/istanbul-exclusions.ts +0 -1
  18. package/.config/testing-exclusions/vitest-exclusions.ts +0 -8
  19. package/.config/ts/tsconfig.lint.json +0 -10
  20. package/.config/vitest.config.ts +0 -18
  21. package/.gitattributes +0 -25
  22. package/.github/workflows/ci.yml +0 -54
  23. package/.github/workflows/npm-publish.yml +0 -27
  24. package/.husky/pre-commit +0 -1
  25. package/.idea/codeStyles/Project.xml +0 -59
  26. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  27. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  28. package/.idea/modules.xml +0 -8
  29. package/.idea/prettier.xml +0 -7
  30. package/.idea/runConfigurations/_template__of_Vitest.xml +0 -9
  31. package/.idea/runConfigurations/build.xml +0 -13
  32. package/.idea/runConfigurations/coverage.xml +0 -12
  33. package/.idea/runConfigurations/lint.xml +0 -13
  34. package/.idea/runConfigurations/lint_code.xml +0 -13
  35. package/.idea/vcs.xml +0 -6
  36. package/.idea/xenopomp-essentials-js.iml +0 -14
  37. package/.prettierrc +0 -20
  38. package/README.md +0 -0
  39. package/__tests__/assets/assertions/expect-deep-equal.ts +0 -14
  40. package/__tests__/assets/assertions/expect-to-render.ts +0 -26
  41. package/__tests__/assets/assertions/index.ts +0 -3
  42. package/__tests__/assets/assertions/not-throwing.ts +0 -6
  43. package/__tests__/assets/index.ts +0 -1
  44. package/__tests__/data/index.ts +0 -1
  45. package/__tests__/data/parseVersion.data.ts +0 -52
  46. package/__tests__/unit/cli/path-builder.test.ts +0 -39
  47. package/__tests__/unit/components/hoc/jsx-dot-notation/component.test-source.tsx +0 -24
  48. package/__tests__/unit/components/hoc/jsx-dot-notation/hoc.test.tsx +0 -11
  49. package/__tests__/unit/components/metrika.test.tsx +0 -14
  50. package/__tests__/unit/components/react-scan.test.tsx +0 -10
  51. package/__tests__/unit/eslint/config.test.tsx +0 -41
  52. package/__tests__/unit/utils/capitalize.test.ts +0 -17
  53. package/__tests__/unit/utils/minmax.test.ts +0 -21
  54. package/__tests__/unit/utils/parseVersion.test.ts +0 -22
  55. package/__tests__/unit/utils/pipe.test.ts +0 -23
  56. package/__tests__/unit/utils/transliterate.test.ts +0 -17
  57. package/_templates/generator/help/index.ejs.t +0 -5
  58. package/_templates/generator/new/hello.ejs.t +0 -18
  59. package/_templates/generator/with-prompt/hello.ejs.t +0 -18
  60. package/_templates/generator/with-prompt/prompt.ejs.t +0 -14
  61. package/_templates/init/repo/new-repo.ejs.t +0 -4
  62. package/_templates/type/new/module.ejs.t +0 -7
  63. package/_templates/type/new/type.ejs.t +0 -7
  64. package/_templates/util/new/func.ejs.t +0 -7
  65. package/_templates/util/new/module.ejs.t +0 -7
  66. package/_templates/util/new/test.ejs.t +0 -13
  67. package/eslint.config.ts +0 -17
  68. package/src/cli-tools/changeFile.ts +0 -1
  69. package/src/cli-tools/index.ts +0 -2
  70. package/src/cli-tools/pathBuilder.ts +0 -89
  71. package/src/eslint/config.ts +0 -145
  72. package/src/eslint/configs/all.ts +0 -74
  73. package/src/eslint/configs/deprecation.ts +0 -33
  74. package/src/eslint/configs/index.ts +0 -7
  75. package/src/eslint/configs/markdown.ts +0 -30
  76. package/src/eslint/configs/next.ts +0 -40
  77. package/src/eslint/configs/old.ts +0 -67
  78. package/src/eslint/configs/prettier.ts +0 -6
  79. package/src/eslint/configs/react.ts +0 -18
  80. package/src/eslint/index.ts +0 -7
  81. package/src/eslint/prefixes/author.ts +0 -2
  82. package/src/eslint/prefixes/index.ts +0 -1
  83. package/src/eslint/types/configs.ts +0 -4
  84. package/src/eslint/types/custom-config.ts +0 -4
  85. package/src/eslint/types/index.ts +0 -2
  86. package/src/index.ts +0 -3
  87. package/src/next/Metrika/Metrika.props.ts +0 -11
  88. package/src/next/Metrika/Metrika.tsx +0 -56
  89. package/src/next/ReactScan/ReactScan.tsx +0 -33
  90. package/src/next/index.ts +0 -2
  91. package/src/react/hoc/index.ts +0 -1
  92. package/src/react/hoc/jsxDotNotation.tsx +0 -38
  93. package/src/react/index.ts +0 -1
  94. package/src/repo-eslint-rules/deep-type-naming.rule.ts +0 -49
  95. package/src/repo-eslint-rules/index.ts +0 -9
  96. package/src/schemas/import-meta.schema.ts +0 -12
  97. package/src/schemas/index.ts +0 -1
  98. package/src/types/aliases/AnyObject.ts +0 -5
  99. package/src/types/aliases/EmptyObject.ts +0 -8
  100. package/src/types/aliases/Fn.ts +0 -12
  101. package/src/types/aliases/index.ts +0 -3
  102. package/src/types/index.ts +0 -4
  103. package/src/types/next/NextParams.ts +0 -26
  104. package/src/types/next/index.ts +0 -1
  105. package/src/types/react/AnyFc.ts +0 -6
  106. package/src/types/react/AsyncFC.ts +0 -16
  107. package/src/types/react/DataAttributes.ts +0 -21
  108. package/src/types/react/FCProps.ts +0 -19
  109. package/src/types/react/FunctionalChildren.ts +0 -13
  110. package/src/types/react/SetState.ts +0 -11
  111. package/src/types/react/VariableFC.ts +0 -48
  112. package/src/types/react/VariableProps.ts +0 -9
  113. package/src/types/react/index.ts +0 -8
  114. package/src/types/utilities/ArrayType.ts +0 -12
  115. package/src/types/utilities/AsyncReturnType.ts +0 -14
  116. package/src/types/utilities/DeepInject.ts +0 -22
  117. package/src/types/utilities/Defined.ts +0 -5
  118. package/src/types/utilities/Jsonish.ts +0 -11
  119. package/src/types/utilities/LenientAutocomplete.ts +0 -24
  120. package/src/types/utilities/MatchType.ts +0 -26
  121. package/src/types/utilities/MergeTypes.ts +0 -12
  122. package/src/types/utilities/Modify.ts +0 -10
  123. package/src/types/utilities/Nullable.ts +0 -5
  124. package/src/types/utilities/OneOf.ts +0 -42
  125. package/src/types/utilities/Prettify.ts +0 -15
  126. package/src/types/utilities/RecordKey.ts +0 -9
  127. package/src/types/utilities/RecordValue.ts +0 -9
  128. package/src/types/utilities/ReplaceReturnType.ts +0 -10
  129. package/src/types/utilities/SelectivePartial.ts +0 -17
  130. package/src/types/utilities/StrictOmit.ts +0 -19
  131. package/src/types/utilities/Synchronous.ts +0 -18
  132. package/src/types/utilities/Undefinable.ts +0 -5
  133. package/src/types/utilities/WeakOmit.ts +0 -17
  134. package/src/types/utilities/Writeable.ts +0 -18
  135. package/src/types/utilities/index.ts +0 -24
  136. package/src/utils/capitalize.ts +0 -15
  137. package/src/utils/index.ts +0 -7
  138. package/src/utils/minmax.ts +0 -35
  139. package/src/utils/parseVersion.ts +0 -42
  140. package/src/utils/pipe.ts +0 -29
  141. package/src/utils/transliterate.ts +0 -8
  142. package/tsconfig.json +0 -43
@@ -1,19 +0,0 @@
1
- import type { FC } from 'react';
2
-
3
- /**
4
- * @deprecated use {@link FCProps} instead.
5
- */
6
- export type FcProps<Comp> = FCProps<Comp>;
7
-
8
- /**
9
- * Extracts type of props from FC type.
10
- *
11
- * @since 0.0.1
12
- * @example
13
- * type Props = FcProps<FC<{ align?: boolean }>>;
14
- * // ^? { align?: boolean }
15
- *
16
- * type VariableProps = FcProps<VariableFC<'button', { notAlign?: boolean }>>;
17
- * // ^? {notAlign?: boolean} & Omit<ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement>, undefined>
18
- */
19
- export type FCProps<Comp> = Comp extends FC<infer Props> ? Props : never;
@@ -1,13 +0,0 @@
1
- import type { ReactNode } from 'react';
2
-
3
- /**
4
- * This type allows you to make children that can be function.
5
- *
6
- * @since 0.0.1
7
- * @example
8
- * type Child = FunctionalChildren<[options: string]>;
9
- * // ReactNode | ((options: string) => ReactNode)
10
- */
11
- export type FunctionalChildren<Args extends any[]> =
12
- | ReactNode
13
- | ((...args: Args) => ReactNode);
@@ -1,11 +0,0 @@
1
- import type { Dispatch, SetStateAction } from 'react';
2
-
3
- /**
4
- * Type of set state function from useState.
5
- *
6
- * @since 0.0.1
7
- * @example
8
- * // typeof setState => SetState<string>
9
- * const [state, setState] = useState<string>('example');
10
- */
11
- export type SetState<TType> = Dispatch<SetStateAction<TType>>;
@@ -1,48 +0,0 @@
1
- import type { ComponentProps, ElementType, FC } from 'react';
2
-
3
- import type { AsyncFC, WeakOmit } from '@/types';
4
-
5
- /**
6
- * This type wraps ComponentProps<A> to your FC.
7
- *
8
- * - __A__ - element type
9
- * - __P__ - wrapping props
10
- * - __Ex__ - excluded component props (for example, if you do not want to include 'children' prop in component)
11
- *
12
- * @since 0.0.1
13
- *
14
- * @example
15
- * type VariableComponentPropsWithChildren = ComponentProps<VariableFC<'div'>>;
16
- * type VariableComponentPropsWithoutChildren = ComponentProps<VariableFC<'div', {}, 'children'>>;
17
- *
18
- * @example
19
- * // With children
20
- * const VariableComponent: VariableFC<'section', { variant?: 'default' }> = ({ variant, ...props }) => {
21
- * return <section {...props}></section>
22
- * }
23
- *
24
- * @example
25
- * // Without children
26
- * const VariableComponent: VariableFC<'section', { variant?: 'default' }, 'children'> = ({ variant, ...props }) => {
27
- * return (
28
- * <section {...props}>
29
- * <div>Insert your own children</div>
30
- * </section>
31
- * );
32
- * }
33
- */
34
- export type VariableFC<
35
- A extends ElementType,
36
- P = unknown,
37
- Ex extends keyof ComponentProps<A> | undefined = undefined,
38
- > = FC<P & WeakOmit<ComponentProps<A>, Ex>>;
39
-
40
- /**
41
- * Works similar to {@link VariableFC}, but return type is Promise<ReactNode>;
42
- * @since 0.0.1
43
- */
44
- export type AsyncVariableFC<
45
- A extends ElementType,
46
- P = unknown,
47
- Ex extends keyof ComponentProps<A> | undefined = undefined,
48
- > = AsyncFC<P & WeakOmit<ComponentProps<A>, Ex>>;
@@ -1,9 +0,0 @@
1
- import type { ComponentProps, ElementType } from 'react';
2
-
3
- import type { FCProps, VariableFC } from '@/types';
4
-
5
- export type VariableProps<
6
- A extends ElementType,
7
- P = unknown,
8
- Ex extends keyof ComponentProps<A> | undefined = undefined,
9
- > = FCProps<VariableFC<A, P, Ex>>;
@@ -1,8 +0,0 @@
1
- export * from './VariableFC';
2
- export * from './AsyncFC';
3
- export * from './SetState';
4
- export * from './FunctionalChildren';
5
- export * from './FCProps';
6
- export * from './AnyFc';
7
- export * from './DataAttributes';
8
- export * from './VariableProps';
@@ -1,12 +0,0 @@
1
- /**
2
- * This type gets type of array`s item.
3
- *
4
- * @since 0.0.1
5
- * @example
6
- * type Super = ArrayType<string[]>; // string
7
- *
8
- * type Good = ArrayType<(string|number)[]>; // string | number
9
- */
10
- export type ArrayType<T> = T extends Array<infer A> ? A : never;
11
-
12
- export type ArrayItemType<T> = ArrayType<T>;
@@ -1,14 +0,0 @@
1
- /**
2
- * Get return type of function that returns Promise ((...args: any) => Promise<any>).
3
- *
4
- * @since 0.0.1
5
- * @example
6
- * const doSomething = async (): Promise<string|number> => {
7
- * return 'result';
8
- * }
9
- *
10
- * type Something = PromiseReturnType<typeof doSomething>;
11
- * // string|number
12
- */
13
- export type AsyncReturnType<F extends (...args: any[]) => Promise<any>> =
14
- Awaited<ReturnType<F>>;
@@ -1,22 +0,0 @@
1
- import type { AnyObject } from '@/types';
2
-
3
- /**
4
- * @deprecated Use {@link InjectDeep} instead.
5
- */
6
- type DeepInject<T, I extends AnyObject> = InjectDeep<T, I>;
7
-
8
- /**
9
- * Recursively add some type inside all keys of target type.
10
- *
11
- * @since 0.0.1
12
- * @example
13
- * type Sups = DeepInject<{ supa: { sups: number } }, { _ignore: boolean }>;
14
- * const asp: Sups = { supa: { sups: 1, _ignore: false }, _ignore: false };
15
- */
16
- export type InjectDeep<T, I extends AnyObject> = T extends object
17
- ? {
18
- [K in keyof T]: T[K] extends object
19
- ? T[K] & I & DeepInject<T[K], I>
20
- : T[K];
21
- } & I
22
- : T;
@@ -1,5 +0,0 @@
1
- /**
2
- * Removes undefined from union type.
3
- * @since 0.0.1
4
- */
5
- export type Defined<T> = Exclude<T, undefined>;
@@ -1,11 +0,0 @@
1
- import type { Jsonifiable } from 'type-fest';
2
-
3
- /**
4
- * Return never if type does not match JSON schema.
5
- *
6
- * @since 0.0.1
7
- * @example
8
- * type Schema = Jsonish<{ sus: string; am: string; }>; // OK
9
- * type AlterSchema = Jsonish<{ sus: string; am: () => {}; }>; // Causes error
10
- */
11
- export type Jsonish<T extends Jsonifiable> = T extends Jsonifiable ? T : never;
@@ -1,24 +0,0 @@
1
- /**
2
- * Makes types don`t merging in unions.
3
- *
4
- * @since 0.0.1
5
- * @example
6
- * type Languages = 'TypeScript' | 'JavaScript' | Lenient<string>;
7
- * // ^? "TypeScript" | "JavaScript" | string
8
- */
9
- export type Lenient<T> = T & {};
10
-
11
- /**
12
- * This type allows any string, but also saves compiler`s autocomplete
13
- * feature.
14
- *
15
- * @since 0.0.1
16
- * @example
17
- * type Languages = 'TypeScript' | 'JavaScript';
18
- *
19
- * function handleLanguage(lang: LenientAutocomplete<Languages>) {
20
- * // ^? string (but autocomplete feature is still here)
21
- * console.log(lang);
22
- * }
23
- */
24
- export type LenientAutocomplete<T extends string> = T | Lenient<string>;
@@ -1,26 +0,0 @@
1
- /**
2
- * Checks if type **T** matches type **M**.
3
- *
4
- * @since 0.0.1
5
- *
6
- * @example Not matching
7
- * type ViewStyles = {
8
- * paddingHorizontal: number
9
- * }
10
- *
11
- * type Styles = MatchType<{}, ViewStyles>; // TSERROR
12
- *
13
- * @example Matching
14
- * type ViewStyles = {
15
- * paddingHorizontal: number;
16
- * };
17
- *
18
- * // No error
19
- * type Styles = MatchType<
20
- * {
21
- * paddingHorizontal: number;
22
- * },
23
- * ViewStyles
24
- * >;
25
- */
26
- export type MatchType<T extends M, M> = T extends M ? T : never;
@@ -1,12 +0,0 @@
1
- import type { EmptyObject } from '@/types';
2
-
3
- /**
4
- * Merge array of types to one type.
5
- * @since 0.0.1
6
- */
7
- export type MergeTypes<
8
- TypesArray extends any[],
9
- Res = EmptyObject,
10
- > = TypesArray extends [infer Head, ...infer Rem]
11
- ? MergeTypes<Rem, Res & Head>
12
- : Res;
@@ -1,10 +0,0 @@
1
- /**
2
- * Modifies K (Key) in T (Type), replace it with R (Replacement).
3
- *
4
- * @since 0.0.1
5
- * @example
6
- * type ExcludedStore = Modify<IStore, 'appSettings', { appName: 'Simple name' }>; // Key in IStore has been replaced with new type.
7
- */
8
- export type Modify<T, K extends keyof T, R> = Omit<T, K> & {
9
- [Key in K]: R;
10
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * Make union type of T and null.
3
- * @since 0.0.1
4
- */
5
- export type Nullable<T> = T | null;
@@ -1,42 +0,0 @@
1
- import type { MergeTypes } from '@/types';
2
-
3
- /**
4
- * Extracts first type from two generics. Is helper type for {@link OneOf} type.
5
- * @since 0.0.1
6
- */
7
- export type OnlyFirst<F, S> = F & { [Key in keyof Omit<S, keyof F>]?: never };
8
-
9
- /**
10
- * Chooses only one of types array.
11
- *
12
- * @since 0.0.1
13
- * @example
14
- * type Email = {
15
- * person: string;
16
- * content: string;
17
- * address: string;
18
- * };
19
- *
20
- * type Mail = {
21
- * person: string;
22
- * content: string;
23
- * postCode: number;
24
- * };
25
- *
26
- * type Letter = OneOf<[Email, Mail]>;
27
- *
28
- * // Will error, cause address is not assignable to type never.
29
- * const email: Letter = {
30
- * person: 'person',
31
- * content: 'content',
32
- * address: '',
33
- * postCode: 12,
34
- * };
35
- */
36
- export type OneOf<
37
- TypesArray extends any[],
38
- Res = never,
39
- AllProperties = MergeTypes<TypesArray>,
40
- > = TypesArray extends [infer Head, ...infer Rem]
41
- ? OneOf<Rem, Res | OnlyFirst<Head, AllProperties>, AllProperties>
42
- : Res;
@@ -1,15 +0,0 @@
1
- import type { AnyObject } from '@/types';
2
-
3
- /**
4
- * Presents plain object in pretty form.
5
- */
6
- export type Prettify<T> = {
7
- [K in keyof T]: T[K];
8
- } & {};
9
-
10
- /**
11
- * Presents object in pretty form recursively.
12
- */
13
- export type PrettifyDeep<T> = {
14
- [K in keyof T]: T[K] extends AnyObject ? Prettify<PrettifyDeep<T[K]>> : T[K];
15
- };
@@ -1,9 +0,0 @@
1
- /**
2
- * Get typeof key of Record.
3
- *
4
- * @since 0.0.1
5
- * @example
6
- * type Key = RecordKey<Record<string, number>>; // string
7
- */
8
- export type RecordKey<R extends Record<any, any>> =
9
- R extends Record<infer K, any> ? K : never;
@@ -1,9 +0,0 @@
1
- /**
2
- * Get typeof value of Record.
3
- *
4
- * @since 0.0.1
5
- * @example
6
- * type Value = RecordValue<Record<string, number>>; // number
7
- */
8
- export type RecordValue<R extends Record<any, any>> =
9
- R extends Record<any, infer V> ? V : never;
@@ -1,10 +0,0 @@
1
- /**
2
- * This type replace return type of function with other type.
3
- *
4
- * @since 0.0.1
5
- * @example
6
- * type StringFC<T = {}> = ReplaceReturnType<FC<T>, string>;
7
- */
8
- export type ReplaceReturnType<TFn, TR> = TFn extends (...a: infer A) => any
9
- ? (...a: A) => TR
10
- : never;
@@ -1,17 +0,0 @@
1
- /**
2
- * Works as Partial, but makes only specified keys partial.
3
- *
4
- * @since 0.0.1
5
- * @example
6
- * type Super = SelectivePartial<{
7
- * name: string;
8
- * address: {
9
- * street: string;
10
- * number: number
11
- * }
12
- * }, 'address'>;
13
- *
14
- * // Property 'address' will be partial.
15
- */
16
- export type SelectivePartial<T, K extends keyof T> = Omit<T, K> &
17
- Partial<Pick<T, K>>;
@@ -1,19 +0,0 @@
1
- /**
2
- * The strict version of Omit. Allows to remove only
3
- * keys that are presented in T type.
4
- *
5
- * @since 0.0.1
6
- * @example
7
- * type Tree = {
8
- * height: number;
9
- * age: number;
10
- * name: string;
11
- * };
12
- *
13
- * // TS2344: Type 'weight' does not satisfy the constraint keyof Tree
14
- * type TreeInfo = StrictOmit<Tree, 'weight'>;
15
- *
16
- * // Works just like usual Omit
17
- * type CorrectTreeInfo = StrictOmit<Tree, 'name'>;
18
- */
19
- export type StrictOmit<T, K extends keyof T> = Omit<T, K>;
@@ -1,18 +0,0 @@
1
- import type { Fn, ReplaceReturnType } from '@/types';
2
-
3
- /**
4
- * Make any async func synchronous.
5
- *
6
- * Return never, if __Func__ is not a function, actually.
7
- *
8
- * @since 0.0.1
9
- * @example
10
- * type NormalFunc = Synchronous<(one: string, two: number) => void>; // (one: string, two: number) => void
11
- * type AsyncFunc = Synchronous<(one: string, two: number) => Promise<void>>; // (one: string, two: number) => void
12
- * type NotAFunc = Synchronous<'sus'>; // never
13
- */
14
- export type Synchronous<Func> = Func extends Fn
15
- ? Func extends (...args: any[]) => Promise<infer Result>
16
- ? ReplaceReturnType<Func, Result>
17
- : Func
18
- : never;
@@ -1,5 +0,0 @@
1
- /**
2
- * Makes type union of type T and undefined
3
- * @since 0.0.1
4
- */
5
- export type Undefinable<T> = T | undefined;
@@ -1,17 +0,0 @@
1
- import type { AnyObject } from '@/types';
2
-
3
- /**
4
- * Allows to pass undefined as Omit`s generic. Weakly omits type.
5
- *
6
- * @since 0.0.1
7
- * @example
8
- * // Will not omit any keys
9
- * type Lib = WeakOmit<{ bookCount: number; date: string }, undefined>;
10
- *
11
- * // Will omit
12
- * type LibStrong = WeakOmit<{ bookCount: number; date: string }, 'date'>;
13
- */
14
- export type WeakOmit<
15
- Obj extends AnyObject,
16
- Keys extends keyof Obj | undefined = undefined,
17
- > = Keys extends keyof Obj ? Omit<Obj, Keys> : Obj;
@@ -1,18 +0,0 @@
1
- /**
2
- * Removes readonly from type.
3
- * @since 0.0.1
4
- */
5
- export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
6
-
7
- /**
8
- * @deprecated Use {@link WriteableDeep} instead.
9
- */
10
- type DeepWriteable<T> = WriteableDeep<T>;
11
-
12
- /**
13
- * Removes readonly from type deeply.
14
- * @since 0.0.1
15
- */
16
- export type WriteableDeep<T> = {
17
- -readonly [P in keyof T]: DeepWriteable<T[P]>;
18
- };
@@ -1,24 +0,0 @@
1
- export * from './Synchronous';
2
- export * from './Writeable';
3
- export * from './MatchType';
4
- export * from './ArrayType';
5
- export * from './AsyncReturnType';
6
- export * from './DeepInject';
7
- export * from './Defined';
8
- export * from './Jsonish';
9
- export * from './Modify';
10
- export * from './Nullable';
11
- export * from './RecordKey';
12
- export * from './RecordValue';
13
- export * from './ReplaceReturnType';
14
- export * from './SelectivePartial';
15
- export * from './Undefinable';
16
- export * from './StrictOmit';
17
-
18
- export * from './OneOf';
19
-
20
- export * from './MergeTypes';
21
-
22
- export * from './WeakOmit';
23
- export * from './LenientAutocomplete';
24
- export * from './Prettify';
@@ -1,15 +0,0 @@
1
- /**
2
- * Capitalizes string (makes first letter uppercase).
3
- * @since 0.0.1
4
- */
5
- export function capitalize<T extends string>(str: T): Capitalize<T> {
6
- return (str.charAt(0).toUpperCase() + str.slice(1)) as Capitalize<T>;
7
- }
8
-
9
- /**
10
- * Un-capitalizes string (makes first letter lowercase).
11
- * @since 0.0.1
12
- */
13
- export function uncapitalize<T extends string>(str: T): Uncapitalize<T> {
14
- return (str.charAt(0).toLowerCase() + str.slice(1)) as Uncapitalize<T>;
15
- }
@@ -1,7 +0,0 @@
1
- export * from './pipe';
2
- export * from './capitalize';
3
-
4
- export * from './parseVersion';
5
- export * from './transliterate';
6
-
7
- export * from './minmax';
@@ -1,35 +0,0 @@
1
- /**
2
- * Constraints number with min and max values.
3
- *
4
- * @example Min value
5
- * console.log({
6
- * ogNum: 1, // 1
7
- * minmax: minmax(1, [2, undefined]), // 2
8
- * });
9
- *
10
- * @example Max value
11
- * console.log({
12
- * ogNum: 1001, // 1001
13
- * minmax: minmax(1001, [undefined, 900]), // 900
14
- * });
15
- *
16
- * @example Min and max value
17
- * console.log({
18
- * ogNum: 600, // 600
19
- * minmax: minmax(1001, [2, 900]), // 600
20
- * });
21
- */
22
- export const minmax = (
23
- num: number,
24
- [min, max]: [min: number | undefined, max: number | undefined],
25
- ) => {
26
- if (!!min && num <= min) {
27
- return min;
28
- }
29
-
30
- if (!!max && num >= max) {
31
- return max;
32
- }
33
-
34
- return num;
35
- };
@@ -1,42 +0,0 @@
1
- import type { LenientAutocomplete, Nullable } from '@/types';
2
-
3
- export type Preid = 'alpha' | 'beta' | 'rc';
4
-
5
- export interface VersionData {
6
- /** Version in format: (__``x.x.x``__-beta.x) */
7
- version: Nullable<string>;
8
-
9
- /** Version preid. (x.x.x-__``beta``__.x) */
10
- preid?: LenientAutocomplete<Preid>;
11
-
12
- /** Number of pre-release. (x.x.x-beta.__``12``__) */
13
- prerelease?: string;
14
- }
15
-
16
- /**
17
- * Parses version with preid.
18
- *
19
- * @since 0.0.1
20
- *
21
- * @param raw
22
- *
23
- * @example
24
- * const { version, preid } = parseVersion('0.0.0-beta.0');
25
- * // version = '0.0.0'
26
- * // preid = 'beta'
27
- */
28
- export const parseVersion = (raw: string): VersionData => {
29
- /** Parsed version. */
30
- // eslint-disable-next-line regexp/no-useless-flag,regexp/no-unused-capturing-group
31
- const version = raw.match(/(\d\.){2}\d/gi)?.at(0) || null;
32
- // eslint-disable-next-line regexp/no-useless-flag
33
- const preid = raw.match(/(?<=-)\w+(?=\.\d)/gi)?.at(0);
34
- // eslint-disable-next-line regexp/no-useless-flag,regexp/no-unused-capturing-group
35
- const prerelease = raw.match(/(?<=((\d\.){2}\d-\w+\.))\d+/gi)?.at(0);
36
-
37
- return {
38
- version,
39
- preid,
40
- prerelease,
41
- };
42
- };
package/src/utils/pipe.ts DELETED
@@ -1,29 +0,0 @@
1
- /**
2
- * Creates pipelines of functions that will be executed only
3
- * when you will call whole pipeline.
4
- *
5
- * @since 0.0.1
6
- *
7
- * @param fn
8
- *
9
- * @example
10
- * const stringToDateAndTime = pipe(Date.parse)
11
- * .pipe(n => new Date(n))
12
- * .pipe(d => d.toDateString())
13
- * .pipe(s => s.split('T'))
14
- * .pipe(([date, time]) => ({ date, time }));
15
- *
16
- * const res = stringToDateAndTime('Jan 1, 2024');
17
- * // ^? { date: string | undefined; time: string | undefined }
18
- *
19
- * @see https://youtu.be/bH61wRMqp-o?si=D-2Az-_dUFBxG9HG&t=429
20
- */
21
- export function pipe<A, B>(fn: (a: A) => B) {
22
- function run(a: A) {
23
- return fn(a);
24
- }
25
-
26
- run.pipe = <C>(fn2: (b: B) => C) => pipe((a: A) => fn2(fn(a)));
27
-
28
- return run;
29
- }
@@ -1,8 +0,0 @@
1
- import { transliterate as t } from 'transliteration';
2
-
3
- /**
4
- * Transforms any given string to transliterated variant.
5
- *
6
- * @since 0.0.1
7
- */
8
- export const transliterate = t;