@luminix/support 0.0.1-beta.7 → 0.1.0-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luminix/support",
3
- "version": "0.0.1-beta.7",
3
+ "version": "0.1.0-beta.0",
4
4
  "module": "dist/support.js",
5
5
  "types": "types/index.d.ts",
6
6
  "type": "module",
package/types/Arr.d.ts CHANGED
@@ -1,18 +1,25 @@
1
- /**
2
- *
3
- * Calculates the Cartesian product of the given arrays.
4
- *
5
- */
6
- export declare function cartesian<T>(...arrays: T[][]): T[][];
7
- /**
8
- *
9
- * Gets an array of random elements from the given `array`.
10
- *
11
- */
12
- export declare function sampleSize(array: any[], n: number): any[];
13
- /**
14
- *
15
- * Returns a shuffled copy of `array`.
16
- *
17
- */
18
- export declare function shuffle<T>(array: T[]): T[];
1
+ export declare class ArrMacros {
2
+ [x: string]: (...args: any[]) => any;
3
+ }
4
+ declare class ArrStatic {
5
+ /**
6
+ *
7
+ * Calculates the Cartesian product of the given arrays.
8
+ *
9
+ */
10
+ cartesian<T>(...arrays: T[][]): T[][];
11
+ /**
12
+ *
13
+ * Gets an array of random elements from the given `array`.
14
+ *
15
+ */
16
+ sampleSize(array: any[], n: number): any[];
17
+ /**
18
+ *
19
+ * Returns a shuffled copy of `array`.
20
+ *
21
+ */
22
+ shuffle<T>(array: T[]): T[];
23
+ }
24
+ declare const Arr: ArrStatic & ArrMacros & import('./Mixins/Macroable').MacroableInterface<ArrMacros>;
25
+ export default Arr;
@@ -5,10 +5,14 @@ export type Event<TData = any, TSource extends EventSource = any> = TData & {
5
5
  export type EventMap = {
6
6
  [key: string]: (event: Event) => void;
7
7
  };
8
+ export type EventMapOf<TSource extends EventSource> = TSource extends EventSource<infer T> ? T : never;
9
+ export type EventsOf<TSource extends EventSource> = keyof EventMapOf<TSource>;
10
+ export type EventCallbackOf<TSource extends EventSource, E extends EventsOf<TSource>> = EventMapOf<TSource>[E];
8
11
  export default class EventSource<TEvents extends EventMap = EventMap> {
9
12
  private emitter;
10
13
  constructor();
11
14
  on<E extends keyof TEvents>(event: E, callback: TEvents[E]): Unsubscribe;
12
15
  once<E extends keyof TEvents>(event: E, callback: TEvents[E]): void;
13
16
  emit<E extends keyof TEvents>(event: E, ...data: Parameters<TEvents[E]>): void;
17
+ flushEvents(): void;
14
18
  }
@@ -0,0 +1,2 @@
1
+ export declare function parse(value: Date | string): Date;
2
+ export declare function toDateTimeLocal(value: Date | string): string;
@@ -0,0 +1,3 @@
1
+ import { DebouncedFunc, DebounceSettings, ThrottleSettings } from 'lodash-es';
2
+ export declare function throttle<T extends (...args: any) => any>(func: T, wait?: number, options?: ThrottleSettings): DebouncedFunc<T>;
3
+ export declare function debounce<T extends (...args: any) => any>(func: T, wait?: number, options?: DebounceSettings): DebouncedFunc<T>;
@@ -1,12 +1,14 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  export default class Response<TResponse = any, TData = any> {
3
- private response;
4
- private error?;
5
- constructor(response: AxiosResponse<TResponse, TData>, error?: Error | undefined);
3
+ protected _response: AxiosResponse<TResponse, TData>;
4
+ protected _error?: Error | undefined;
5
+ constructor(_response: AxiosResponse<TResponse, TData>, _error?: Error | undefined);
6
+ error(): Error | undefined;
6
7
  body(): string;
7
8
  json(): TResponse;
8
9
  json<K extends keyof TResponse>(key: K): TResponse[K];
9
10
  json(key: string, defaultValue?: any): any;
11
+ has(key: string): boolean;
10
12
  status(): number;
11
13
  successful(): boolean;
12
14
  redirect(): boolean;
package/types/Obj.d.ts CHANGED
@@ -1,14 +1,20 @@
1
- export type JsonProperty = null | boolean | number | string;
2
- export declare function fromQuery(searchParams: URLSearchParams): Record<string, any>;
3
- export declare function fromFormData(formData: FormData): Record<string, any>;
4
- export declare function get(object: any, path: string, defaultValue?: any): any;
5
- export declare function has(object: any, path: string): boolean;
6
- export declare function isEmpty(object: any): boolean;
7
- export declare function isEqual(object: any, other: any): boolean;
8
- export declare function merge(object: any, ...sources: any[]): any;
9
- export declare function omit(object: any, ...paths: string[]): any;
10
- export declare function pick(object: any, ...paths: string[]): any;
11
- export declare function set(object: any, path: string, value: any): void;
12
- export declare function toQuery(object: any): URLSearchParams;
13
- export declare function toFormData(object: any): FormData;
14
- export declare function unset(object: any, path: string): void;
1
+ export declare class ObjMacros {
2
+ [x: string]: (...args: any[]) => any;
3
+ }
4
+ export declare class ObjStatic {
5
+ fromQuery(searchParams: URLSearchParams): Record<string, any>;
6
+ fromFormData(formData: FormData): Record<string, any>;
7
+ get(object: any, path: string, defaultValue?: any): any;
8
+ has(object: any, path: string): boolean;
9
+ isEmpty(object: any): boolean;
10
+ isEqual(object: any, other: any): boolean;
11
+ merge(object: any, ...sources: any[]): any;
12
+ omit(object: any, ...paths: string[]): any;
13
+ pick(object: any, ...paths: string[]): any;
14
+ set(object: any, path: string, value: any): void;
15
+ toQuery(object: any): URLSearchParams;
16
+ toFormData(object: any): FormData;
17
+ unset(object: any, path: string): void;
18
+ }
19
+ declare const Obj: ObjStatic & ObjMacros & import('./Mixins/Macroable').MacroableInterface<ObjMacros>;
20
+ export default Obj;
package/types/Query.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export type Operator = '=' | '!=' | '>' | '>=' | '<' | '<=';
2
2
  export declare function fromObject(object: object): URLSearchParams;
3
- export declare function toObject(searchParams: URLSearchParams): object;
3
+ export declare function toObject(searchParams: URLSearchParams): Record<string, any>;
4
4
  export declare function merge(...parts: (string | URLSearchParams)[]): URLSearchParams;
package/types/Str.d.ts CHANGED
@@ -3,8 +3,16 @@ export declare function afterLast(string: string, search: string): string;
3
3
  export declare function before(string: string, search: string): string;
4
4
  export declare function beforeLast(string: string, search: string): string;
5
5
  export declare function camel(string: string): string;
6
+ export declare function lcfirst(string: string): string;
7
+ export declare function lower(string: string): string;
6
8
  export declare function kebab(string: string): string;
9
+ export declare function padBoth(string: string, length: number, chars?: string): string;
10
+ export declare function padLeft(string: string, length: number, chars?: string): string;
11
+ export declare function padRight(string: string, length: number, chars?: string): string;
12
+ export declare function readable(string: string): string;
7
13
  export declare function studly(string: string): string;
8
14
  export declare function snake(string: string): string;
15
+ export declare function title(string: string): string;
9
16
  export declare function trim(string: string, chars?: string): string;
10
- export declare function upperFirst(string: string): string;
17
+ export declare function ucfirst(string: string): string;
18
+ export declare function upper(string: string): string;
package/types/index.d.ts CHANGED
@@ -1,26 +1,33 @@
1
+ import { default as axios } from 'axios';
1
2
  import { default as Application } from './App/Application';
2
3
  import { default as Client } from './Http/Client';
3
4
  import { default as Collection } from './Collection';
4
5
  import { default as EventSource } from './Contracts/EventSource';
6
+ import { default as Macroable } from './Mixins/Macroable';
5
7
  import { default as MakeFacade } from './Mixins/MakeFacade';
6
8
  import { default as PropertyBag } from './PropertyBag';
7
9
  import { default as reader } from './reader';
8
10
  import { default as Reducible } from './Mixins/Reducible';
9
11
  import { default as Request } from './Http/Request';
10
12
  import { default as Response } from './Http/Response';
11
- import { default as Macroable } from './Mixins/Macroable';
12
13
  import { default as ServiceProvider } from './App/ServiceProvider';
13
14
  import { default as isValidationError } from './Http/Utils/isValidationError';
14
- import * as Arr from './Arr';
15
- import * as Obj from './Obj';
15
+ import { default as Arr } from './Arr';
16
+ import { default as Obj } from './Obj';
17
+ import * as immer from 'immer';
18
+ import * as DateTime from './DateTime';
19
+ import * as Func from './Func';
16
20
  import * as Query from './Query';
17
21
  import * as Str from './Str';
22
+ export { Application, Arr, Client, Collection, DateTime, EventSource, Func, isValidationError, Macroable, MakeFacade, Obj, PropertyBag, reader, Reducible, Request, Response, ServiceProvider, Query, Str, axios, immer, };
23
+ export type { ArrMacros } from './Arr';
24
+ export type { ObjMacros } from './Obj';
18
25
  export type { ApplicationInterface, ApplicationEvents } from './App/Interfaces';
19
- export type { Event } from './Contracts/EventSource';
26
+ export type { Event, EventMap, EventMapOf, EventsOf, EventCallbackOf } from './Contracts/EventSource';
27
+ export type { RequestOptions } from './Http/Client';
20
28
  export type { MacroableOf, MacroableInterface } from './Mixins/Macroable';
21
29
  export type { HasFacadeAccessor, FacadeOf } from './Mixins/MakeFacade';
22
- export type { ReducibleInterface, ReducibleOf } from './Mixins/Reducible';
23
- export type { PropertyBagEventMap } from './PropertyBag';
30
+ export type { ReducibleInterface, ReducibleOf, ReducerCallback } from './Mixins/Reducible';
31
+ export type { CollectionIteratorCallback } from './Collection';
24
32
  export type { Constructor, TypeOf, JsonObject, JsonValue } from './Js';
25
- export type { RequestOptions } from './Http/Client';
26
- export { Application, Arr, Client, Collection, EventSource, isValidationError, Macroable, MakeFacade, Obj, PropertyBag, reader, Reducible, Request, Response, ServiceProvider, Query, Str, };
33
+ export type { PropertyBagEventMap } from './PropertyBag';
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- vite.config.js
2
- dist/
3
- coverage/
package/.eslintrc.cjs DELETED
@@ -1,39 +0,0 @@
1
- // eslint-disable-next-line no-undef
2
- module.exports = {
3
- 'env': {
4
- 'browser': true,
5
- 'es2021': true
6
- },
7
- 'extends': [
8
- 'eslint:recommended',
9
- 'plugin:@typescript-eslint/recommended'
10
- ],
11
- 'overrides': [
12
- ],
13
- 'parser': '@typescript-eslint/parser',
14
- 'parserOptions': {
15
- 'ecmaVersion': 'latest',
16
- 'sourceType': 'module'
17
- },
18
- 'plugins': [
19
- '@typescript-eslint'
20
- ],
21
- 'rules': {
22
- 'indent': [
23
- 'error',
24
- 4
25
- ],
26
- 'linebreak-style': [
27
- 'error',
28
- 'unix'
29
- ],
30
- 'quotes': [
31
- 'error',
32
- 'single'
33
- ],
34
- 'semi': [
35
- 'error',
36
- 'always'
37
- ]
38
- }
39
- };