@pistachiojs/core 0.1.0 → 0.2.0-dev.1
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/dist/index.d.ts +116 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Excludes values from other array.
|
|
3
|
+
* @param valueA - Array value to compare.
|
|
4
|
+
* @param valueB - Array value to compare.
|
|
5
|
+
* @param compareFn - Function to determine equality between elements.
|
|
6
|
+
* @param options - Configuration object.
|
|
7
|
+
* @returns Array value containing difference based on specified mode.
|
|
8
|
+
*/
|
|
9
|
+
declare function difference<T>(valueA: readonly T[], valueB: readonly T[], compareFn?: (valueA: T, valueB: T) => boolean, options?: {
|
|
10
|
+
symmetric?: boolean;
|
|
11
|
+
}): T[];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Filters an array based on a predicate function.
|
|
15
|
+
* @param value - Array value to filter.
|
|
16
|
+
* @param predicateFn - Function that tests each element.
|
|
17
|
+
* @returns Array value containing only elements that pass test.
|
|
18
|
+
*/
|
|
19
|
+
declare function filter<T>(value: readonly T[], predicateFn: (item: T, index: number, array: readonly T[]) => boolean): T[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Executes a provided function once for each array element.
|
|
23
|
+
* @param value - Array value to iterate over.
|
|
24
|
+
* @param callbackFn - Function to execute for each element.
|
|
25
|
+
*/
|
|
26
|
+
declare function forEach<T>(value: readonly T[], callbackFn: (item: T, index: number, array: readonly T[]) => void): void;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Joins all elements of an array into a string.
|
|
30
|
+
* @param value - Array value to join.
|
|
31
|
+
* @param separator - String to separate each pair of adjacent elements.
|
|
32
|
+
* @returns String value with all array elements joined.
|
|
33
|
+
*/
|
|
34
|
+
declare function join<T>(value: readonly T[], separator?: string): string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new array populated with results of calling a provided function on every element.
|
|
38
|
+
* @param value - Array value to map over.
|
|
39
|
+
* @param callbackFn - Function that produces an element of new array.
|
|
40
|
+
* @returns New array value with each element being result of callback function.
|
|
41
|
+
*/
|
|
42
|
+
declare function map<T, U>(value: readonly T[], callbackFn: (item: T, index: number, array: readonly T[]) => U): U[];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Sorts an array using an compare function.
|
|
46
|
+
* @param value - Array value to sort.
|
|
47
|
+
* @param compareFn - Function that defines sort order.
|
|
48
|
+
* @returns Array value sorted.
|
|
49
|
+
*/
|
|
50
|
+
declare function sort<T>(value: readonly T[], compareFn?: (valueA: T, valueB: T) => number): T[];
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Checks if a value is an array.
|
|
54
|
+
* @param value - Value to check.
|
|
55
|
+
* @returns True if value is an array, false otherwise.
|
|
56
|
+
*/
|
|
57
|
+
declare function isArray(value: unknown): value is unknown[];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Checks if a value is a bigint.
|
|
61
|
+
* @param value - Value to check.
|
|
62
|
+
* @returns True if value is a bigint, false otherwise.
|
|
63
|
+
*/
|
|
64
|
+
declare function isBigInt(value: unknown): value is bigint;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Checks if a value is a boolean.
|
|
68
|
+
* @param value - Value to check.
|
|
69
|
+
* @returns True if value is a boolean, false otherwise.
|
|
70
|
+
*/
|
|
71
|
+
declare function isBoolean(value: unknown): value is boolean;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Checks if a value is a date object.
|
|
75
|
+
* @param value - Value to check.
|
|
76
|
+
* @returns True if value is a date object, false otherwise.
|
|
77
|
+
*/
|
|
78
|
+
declare function isDate(value: unknown): value is Date;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Checks if a value is defined (not null or undefined).
|
|
82
|
+
* @param value - Value to check.
|
|
83
|
+
* @returns True if value is defined, false otherwise.
|
|
84
|
+
*/
|
|
85
|
+
declare function isDefined<T>(value: T | null | undefined): value is T;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Checks if a value is empty (null, undefined, empty string, empty array or empty object).
|
|
89
|
+
* @param value - Value to check.
|
|
90
|
+
* @returns True if value is empty, false otherwise.
|
|
91
|
+
*/
|
|
92
|
+
declare function isEmpty(value: unknown): boolean;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Checks if a value is a function.
|
|
96
|
+
* @param value - Value to check.
|
|
97
|
+
* @returns True if value is a function, false otherwise.
|
|
98
|
+
*/
|
|
99
|
+
declare function isFunction(value: unknown): value is (...args: unknown[]) => unknown;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Freezes an object making it immutable.
|
|
103
|
+
* @param value - Object value to freeze.
|
|
104
|
+
* @returns Object value frozened.
|
|
105
|
+
*/
|
|
106
|
+
declare function freeze<T extends object>(value: T): Readonly<T>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Merges two objects into a new object.
|
|
110
|
+
* @param valueA - Object value to merge.
|
|
111
|
+
* @param valueB - Object value to merge.
|
|
112
|
+
* @returns New object value with properties from both objects.
|
|
113
|
+
*/
|
|
114
|
+
declare function merge<T extends object, U extends object>(valueA: T, valueB: U): T & U;
|
|
115
|
+
|
|
1
116
|
/**
|
|
2
117
|
* Extracts a section of a string between two indices.
|
|
3
118
|
* @param value - String value to slice.
|
|
@@ -95,4 +210,4 @@ declare function toUpperCase(value: string): string;
|
|
|
95
210
|
*/
|
|
96
211
|
declare function truncate(value: string, length: number, suffix?: string): string;
|
|
97
212
|
|
|
98
|
-
export { slice, split, toCamelCase, toCapitalize, toKebabCase, toLowerCase, toPascalCase, toSentenceCase, toSlug, toSnakeCase, toTitleCase, toUpperCase, truncate };
|
|
213
|
+
export { difference, filter, forEach, freeze, isArray, isBigInt, isBoolean, isDate, isDefined, isEmpty, isFunction, join, map, merge, slice, sort, split, toCamelCase, toCapitalize, toKebabCase, toLowerCase, toPascalCase, toSentenceCase, toSlug, toSnakeCase, toTitleCase, toUpperCase, truncate };
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function n(e,t,r){return e.slice(t,
|
|
1
|
+
function l(e,t,n,a){const{symmetric:u=!1}=a??{};if(e.length===0&&t.length===0)return[];if(e.length===0)return u?[...t]:[];if(t.length===0)return[...e];if(!n){const o=new Set(t),r=e.filter(i=>!o.has(i));if(u){const i=new Set(e),s=t.filter(f=>!i.has(f));return[...r,...s]}return r}const c=e.filter(o=>!t.some(r=>n(o,r)));if(u){const o=t.filter(r=>!e.some(i=>n(r,i)));return[...c,...o]}return c}function p(e,t){return e.filter(t)}function g(e,t){e.forEach(t)}function C(e,t){return e.join(t)}function h(e,t){return e.map(t)}function y(e,t){return[...e].sort(t)}function w(e){return Array.isArray(e)}function A(e){return typeof e=="bigint"}function m(e){return typeof e=="boolean"}function L(e){return e instanceof Date}function U(e){return e!=null}function b(e){return e==null?!0:typeof e=="string"||Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function _(e){return typeof e=="function"}function z(e){return Object.freeze(e)}function j(e,t){return{...e,...t}}function S(e,t,n){return e.slice(t,n)}function $(e,t,n){return e.split(t,n)}function d(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase())}function D(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function E(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function Z(e){return e.toLowerCase()}function k(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^[a-z]/,t=>t.toUpperCase())}function B(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function O(e){return e.length===0?e:e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/[\s_]+/g,"-").replace(/^-+|-+$/g,"").replace(/-+/g,"-")}function x(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function F(e){return e.length===0?e:e.toLowerCase().replace(/(?:^|\s|-|_)\w/g,t=>t.toUpperCase())}function I(e){return e.toUpperCase()}function K(e,t,n="..."){return e.length<=t?e:t-n.length<=0?n.slice(0,t):e.slice(0,t-n.length)+n}export{l as difference,p as filter,g as forEach,z as freeze,w as isArray,A as isBigInt,m as isBoolean,L as isDate,U as isDefined,b as isEmpty,_ as isFunction,C as join,h as map,j as merge,S as slice,y as sort,$ as split,d as toCamelCase,D as toCapitalize,E as toKebabCase,Z as toLowerCase,k as toPascalCase,B as toSentenceCase,O as toSlug,x as toSnakeCase,F as toTitleCase,I as toUpperCase,K as truncate};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function r(e,t,a){return e.slice(t,
|
|
1
|
+
"use strict";function f(e,t,n,c){const{symmetric:a=!1}=c??{};if(e.length===0&&t.length===0)return[];if(e.length===0)return a?[...t]:[];if(t.length===0)return[...e];if(!n){const o=new Set(t),r=e.filter(i=>!o.has(i));if(a){const i=new Set(e),u=t.filter(l=>!i.has(l));return[...r,...u]}return r}const s=e.filter(o=>!t.some(r=>n(o,r)));if(a){const o=t.filter(r=>!e.some(i=>n(r,i)));return[...s,...o]}return s}function p(e,t){return e.filter(t)}function g(e,t){e.forEach(t)}function C(e,t){return e.join(t)}function h(e,t){return e.map(t)}function y(e,t){return[...e].sort(t)}function m(e){return Array.isArray(e)}function w(e){return typeof e=="bigint"}function A(e){return typeof e=="boolean"}function b(e){return e instanceof Date}function L(e){return e!=null}function U(e){return e==null?!0:typeof e=="string"||Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function z(e){return typeof e=="function"}function S(e){return Object.freeze(e)}function _(e,t){return{...e,...t}}function j(e,t,n){return e.slice(t,n)}function d(e,t,n){return e.split(t,n)}function D(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase())}function E(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function $(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function B(e){return e.toLowerCase()}function k(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^[a-z]/,t=>t.toUpperCase())}function Z(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function F(e){return e.length===0?e:e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/[\s_]+/g,"-").replace(/^-+|-+$/g,"").replace(/-+/g,"-")}function I(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function K(e){return e.length===0?e:e.toLowerCase().replace(/(?:^|\s|-|_)\w/g,t=>t.toUpperCase())}function O(e){return e.toUpperCase()}function P(e,t,n="..."){return e.length<=t?e:t-n.length<=0?n.slice(0,t):e.slice(0,t-n.length)+n}exports.difference=f,exports.filter=p,exports.forEach=g,exports.freeze=S,exports.isArray=m,exports.isBigInt=w,exports.isBoolean=A,exports.isDate=b,exports.isDefined=L,exports.isEmpty=U,exports.isFunction=z,exports.join=C,exports.map=h,exports.merge=_,exports.slice=j,exports.sort=y,exports.split=d,exports.toCamelCase=D,exports.toCapitalize=E,exports.toKebabCase=$,exports.toLowerCase=B,exports.toPascalCase=k,exports.toSentenceCase=Z,exports.toSlug=F,exports.toSnakeCase=I,exports.toTitleCase=K,exports.toUpperCase=O,exports.truncate=P;
|