@pistachiojs/core 0.2.0-dev.1 → 0.2.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/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @pistachiojs/core
2
+
3
+ Framework-agnostic TypeScript utility library with pure functions for common programming tasks. Provides clean, functional utilities that work in any JavaScript environment with zero dependencies.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@pistachiojs/core)](https://www.npmjs.com/package/@pistachiojs/core)
6
+ [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](../../coverage)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ ## Key features
10
+
11
+ - **Full type safety** - TypeScript-first with complete inference
12
+ - **Framework agnostic** - Compatible with any JavaScript framework or library
13
+ - **Zero dependencies** - No external dependencies
14
+ - **Tree shakeable** - Modular imports for minimal bundle size
15
+ - **Well tested** - Comprehensive test coverage
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ # npm
21
+ npm install @pistachiojs/core
22
+
23
+ # pnpm
24
+ pnpm add @pistachiojs/core
25
+
26
+ # yarn
27
+ yarn add @pistachiojs/core
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ### ESM (ES Modules)
33
+
34
+ ```javascript
35
+ import { isArray, toCamelCase } from '@pistachiojs/core'
36
+
37
+ // Type checking
38
+ isArray([1, 2, 3]) // true
39
+ isArray('hello') // false
40
+
41
+ // String transformation
42
+ toCamelCase('hello-world') // 'helloWorld'
43
+ ```
44
+
45
+ ### CommonJS
46
+
47
+ ```javascript
48
+ const { isArray, toCamelCase } = require('@pistachiojs/core')
49
+
50
+ // Type checking
51
+ isArray([1, 2, 3]) // true
52
+ isArray('hello') // false
53
+
54
+ // String transformation
55
+ toCamelCase('hello-world') // 'helloWorld'
56
+ ```
57
+
58
+ ## Type safety
59
+
60
+ This package is written in TypeScript and includes type definitions out of the box.
61
+
62
+ ```typescript
63
+ import { map, isString } from '@pistachiojs/core'
64
+
65
+ // Full type inference
66
+ const numbers: number[] = [1, 2, 3]
67
+ const doubled = map(numbers, (n) => n * 2) // number[]
68
+
69
+ // Type guards narrow types
70
+ function process(value: unknown) {
71
+ if (isString(value)) {
72
+ // value is now typed as string
73
+ return value.toUpperCase()
74
+ }
75
+ }
76
+ ```
77
+
78
+ ## License
79
+
80
+ MIT © [Dirga Prakesha](https://github.com/dirgaprksha)
package/dist/index.d.ts CHANGED
@@ -91,6 +91,13 @@ declare function isDefined<T>(value: T | null | undefined): value is T;
91
91
  */
92
92
  declare function isEmpty(value: unknown): boolean;
93
93
 
94
+ /**
95
+ * Checks if an object is frozen.
96
+ * @param value - Value to check.
97
+ * @returns True if value is a frozen object, false otherwise.
98
+ */
99
+ declare function isFreeze(value: unknown): boolean;
100
+
94
101
  /**
95
102
  * Checks if a value is a function.
96
103
  * @param value - Value to check.
@@ -98,6 +105,48 @@ declare function isEmpty(value: unknown): boolean;
98
105
  */
99
106
  declare function isFunction(value: unknown): value is (...args: unknown[]) => unknown;
100
107
 
108
+ /**
109
+ * Checks if a value is a number (excluding NaN).
110
+ * @param value - Value to check.
111
+ * @returns True if value is a number, false otherwise.
112
+ */
113
+ declare function isNumber(value: unknown): value is number;
114
+
115
+ /**
116
+ * Checks if a value is an object (excluding arrays and null).
117
+ * @param value - Value to check.
118
+ * @returns True if value is an object, false otherwise.
119
+ */
120
+ declare function isObject(value: unknown): value is Record<string, unknown>;
121
+
122
+ /**
123
+ * Checks if a value is a string.
124
+ * @param value - Value to check.
125
+ * @returns True if value is a string, false otherwise.
126
+ */
127
+ declare function isString(value: unknown): value is string;
128
+
129
+ /**
130
+ * Checks if a value is a symbol.
131
+ * @param value - Value to check.
132
+ * @returns True if value is a symbol, false otherwise.
133
+ */
134
+ declare function isSymbol(value: unknown): value is symbol;
135
+
136
+ /**
137
+ * Checks if a value is truthy.
138
+ * @param value - Value to check.
139
+ * @returns True if value is truthy, false otherwise.
140
+ */
141
+ declare function isTruthy<T>(value: T): value is NonNullable<T>;
142
+
143
+ /**
144
+ * Checks if a value is undefined.
145
+ * @param value - Value to check.
146
+ * @returns True if value is undefined, false otherwise.
147
+ */
148
+ declare function isUndefined(value: unknown): value is undefined;
149
+
101
150
  /**
102
151
  * Freezes an object making it immutable.
103
152
  * @param value - Object value to freeze.
@@ -210,4 +259,4 @@ declare function toUpperCase(value: string): string;
210
259
  */
211
260
  declare function truncate(value: string, length: number, suffix?: string): string;
212
261
 
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 };
262
+ export { difference, filter, forEach, freeze, isArray, isBigInt, isBoolean, isDate, isDefined, isEmpty, isFreeze, isFunction, isNumber, isObject, isString, isSymbol, isTruthy, isUndefined, 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 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};
1
+ function l(e,t,r,s){const{symmetric:u=!1}=s??{};if(e.length===0&&t.length===0)return[];if(e.length===0)return u?[...t]:[];if(t.length===0)return[...e];if(!r){const o=new Set(t),n=e.filter(i=>!o.has(i));if(u){const i=new Set(e),f=t.filter(a=>!i.has(a));return[...n,...f]}return n}const c=e.filter(o=>!t.some(n=>r(o,n)));if(u){const o=t.filter(n=>!e.some(i=>r(n,i)));return[...c,...o]}return c}function p(e,t){return e.filter(t)}function g(e,t){e.forEach(t)}function h(e,t){return e.join(t)}function C(e,t){return e.map(t)}function y(e,t){return[...e].sort(t)}function b(e){return Array.isArray(e)}function m(e){return typeof e=="bigint"}function w(e){return typeof e=="boolean"}function A(e){return e instanceof Date}function j(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=="object"&&e!==null&&Object.isFrozen(e)}function L(e){return typeof e=="function"}function S(e){return typeof e=="number"&&!Number.isNaN(e)}function _(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function d(e){return typeof e=="string"}function $(e){return typeof e=="symbol"}function N(e){return!!e}function O(e){return e===void 0}function D(e){return Object.freeze(e)}function E(e,t){return{...e,...t}}function F(e,t,r){return e.slice(t,r)}function Z(e,t,r){return e.split(t,r)}function k(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase())}function B(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function T(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function v(e){return e.toLowerCase()}function x(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^[a-z]/,t=>t.toUpperCase())}function I(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function K(e){return e.length===0?e:e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/[\s_]+/g,"-").replace(/^-+|-+$/g,"").replace(/-+/g,"-")}function P(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function q(e){return e.length===0?e:e.toLowerCase().replace(/(?:^|\s|-|_)\w/g,t=>t.toUpperCase())}function G(e){return e.toUpperCase()}function H(e,t,r="..."){return e.length<=t?e:t-r.length<=0?r.slice(0,t):e.slice(0,t-r.length)+r}export{l as difference,p as filter,g as forEach,D as freeze,b as isArray,m as isBigInt,w as isBoolean,A as isDate,j as isDefined,U as isEmpty,z as isFreeze,L as isFunction,S as isNumber,_ as isObject,d as isString,$ as isSymbol,N as isTruthy,O as isUndefined,h as join,C as map,E as merge,F as slice,y as sort,Z as split,k as toCamelCase,B as toCapitalize,T as toKebabCase,v as toLowerCase,x as toPascalCase,I as toSentenceCase,K as toSlug,P as toSnakeCase,q as toTitleCase,G as toUpperCase,H as truncate};
package/dist/index.js CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";function l(e,t,r,a){const{symmetric:s=!1}=a??{};if(e.length===0&&t.length===0)return[];if(e.length===0)return s?[...t]:[];if(t.length===0)return[...e];if(!r){const o=new Set(t),n=e.filter(i=>!o.has(i));if(s){const i=new Set(e),c=t.filter(f=>!i.has(f));return[...n,...c]}return n}const u=e.filter(o=>!t.some(n=>r(o,n)));if(s){const o=t.filter(n=>!e.some(i=>r(n,i)));return[...u,...o]}return u}function p(e,t){return e.filter(t)}function g(e,t){e.forEach(t)}function C(e,t){return e.join(t)}function y(e,t){return e.map(t)}function h(e,t){return[...e].sort(t)}function b(e){return Array.isArray(e)}function m(e){return typeof e=="bigint"}function w(e){return typeof e=="boolean"}function A(e){return e instanceof Date}function S(e){return e!=null}function j(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=="object"&&e!==null&&Object.isFrozen(e)}function U(e){return typeof e=="function"}function d(e){return typeof e=="number"&&!Number.isNaN(e)}function L(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _(e){return typeof e=="string"}function D(e){return typeof e=="symbol"}function E(e){return!!e}function F(e){return e===void 0}function N(e){return Object.freeze(e)}function O(e,t){return{...e,...t}}function $(e,t,r){return e.slice(t,r)}function B(e,t,r){return e.split(t,r)}function T(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase())}function k(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function Z(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function I(e){return e.toLowerCase()}function K(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^[a-z]/,t=>t.toUpperCase())}function P(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function v(e){return e.length===0?e:e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/[\s_]+/g,"-").replace(/^-+|-+$/g,"").replace(/-+/g,"-")}function q(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function x(e){return e.length===0?e:e.toLowerCase().replace(/(?:^|\s|-|_)\w/g,t=>t.toUpperCase())}function G(e){return e.toUpperCase()}function H(e,t,r="..."){return e.length<=t?e:t-r.length<=0?r.slice(0,t):e.slice(0,t-r.length)+r}exports.difference=l,exports.filter=p,exports.forEach=g,exports.freeze=N,exports.isArray=b,exports.isBigInt=m,exports.isBoolean=w,exports.isDate=A,exports.isDefined=S,exports.isEmpty=j,exports.isFreeze=z,exports.isFunction=U,exports.isNumber=d,exports.isObject=L,exports.isString=_,exports.isSymbol=D,exports.isTruthy=E,exports.isUndefined=F,exports.join=C,exports.map=y,exports.merge=O,exports.slice=$,exports.sort=h,exports.split=B,exports.toCamelCase=T,exports.toCapitalize=k,exports.toKebabCase=Z,exports.toLowerCase=I,exports.toPascalCase=K,exports.toSentenceCase=P,exports.toSlug=v,exports.toSnakeCase=q,exports.toTitleCase=x,exports.toUpperCase=G,exports.truncate=H;
package/package.json CHANGED
@@ -1,9 +1,28 @@
1
1
  {
2
2
  "name": "@pistachiojs/core",
3
- "description": "-",
4
- "version": "0.2.0-dev.1",
3
+ "description": "Framework-agnostic TypeScript utility library with pure functions for common programming tasks",
4
+ "version": "0.2.0",
5
5
  "author": "Dirga Prakesha <dirga.prakesha@gmail.com>",
6
6
  "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dirgaprksha/pistachio.git",
10
+ "directory": "packages/core"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/dirgaprksha/pistachio/issues"
14
+ },
15
+ "keywords": [
16
+ "utility",
17
+ "typescript",
18
+ "javascript",
19
+ "helpers",
20
+ "functional",
21
+ "framework-agnostic",
22
+ "type-safe",
23
+ "tree-shakeable",
24
+ "zero-dependencies"
25
+ ],
7
26
  "sideEffects": false,
8
27
  "main": "dist/index.js",
9
28
  "module": "dist/index.esm.js",