@pistachiojs/core 0.2.0-dev.2 → 0.3.0-dev.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @pistachiojs/core
2
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.
3
+ A TypeScript utility library with pure functions for common programming tasks. Provides clean, functional utilities that work in any JavaScript environment.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@pistachiojs/core)](https://www.npmjs.com/package/@pistachiojs/core)
6
6
  [![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](../../coverage)
package/dist/index.d.ts CHANGED
@@ -147,6 +147,68 @@ declare function isTruthy<T>(value: T): value is NonNullable<T>;
147
147
  */
148
148
  declare function isUndefined(value: unknown): value is undefined;
149
149
 
150
+ /**
151
+ * Adds two numbers together.
152
+ * @param valueA - Number value to add.
153
+ * @param valueB - Number value to add.
154
+ * @returns Number value added.
155
+ */
156
+ declare function add(valueA: number, valueB: number): number;
157
+
158
+ /**
159
+ * Rounds number up to nearest integer.
160
+ * @param value - Number value to round up.
161
+ * @returns Number value rounded.
162
+ */
163
+ declare function ceil(value: number): number;
164
+
165
+ /**
166
+ * Clamps a number within inclusive min and max bounds.
167
+ * @param value - Number value to clamp.
168
+ * @param min - Minimum value bound.
169
+ * @param max - Maximum value bound.
170
+ * @returns Number value clamped.
171
+ */
172
+ declare function clamp(value: number, min: number, max: number): number;
173
+
174
+ /**
175
+ * Divides one number by another.
176
+ * @param valueA - Number value.
177
+ * @param valueB - Number value.
178
+ * @returns Number value divided.
179
+ */
180
+ declare function divide(valueA: number, valueB: number): number;
181
+
182
+ /**
183
+ * Rounds number down to nearest integer.
184
+ * @param value - Number value to round down.
185
+ * @returns Number value rounded.
186
+ */
187
+ declare function floor(value: number): number;
188
+
189
+ /**
190
+ * Multiplies two numbers together.
191
+ * @param valueA - Number value to multiply.
192
+ * @param valueB - Number value to multiply.
193
+ * @returns Number value multipled.
194
+ */
195
+ declare function multiply(valueA: number, valueB: number): number;
196
+
197
+ /**
198
+ * Rounds number to nearest integer.
199
+ * @param value - Number value to round.
200
+ * @returns Number value rounded.
201
+ */
202
+ declare function round(value: number): number;
203
+
204
+ /**
205
+ * Subtracts one number from another.
206
+ * @param valueA - Number value to subtract.
207
+ * @param valueB - Number value to subtract.
208
+ * @returns Number value subtracted.
209
+ */
210
+ declare function subtract(valueA: number, valueB: number): number;
211
+
150
212
  /**
151
213
  * Freezes an object making it immutable.
152
214
  * @param value - Object value to freeze.
@@ -259,4 +321,4 @@ declare function toUpperCase(value: string): string;
259
321
  */
260
322
  declare function truncate(value: string, length: number, suffix?: string): string;
261
323
 
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 };
324
+ export { add, ceil, clamp, difference, divide, filter, floor, forEach, freeze, isArray, isBigInt, isBoolean, isDate, isDefined, isEmpty, isFreeze, isFunction, isNumber, isObject, isString, isSymbol, isTruthy, isUndefined, join, map, merge, multiply, round, slice, sort, split, subtract, toCamelCase, toCapitalize, toKebabCase, toLowerCase, toPascalCase, toSentenceCase, toSlug, toSnakeCase, toTitleCase, toUpperCase, truncate };
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
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};
1
+ function l(e,n,t,f){const{symmetric:i=!1}=f??{};if(e.length===0&&n.length===0)return[];if(e.length===0)return i?[...n]:[];if(n.length===0)return[...e];if(!t){const o=new Set(n),r=e.filter(u=>!o.has(u));if(i){const u=new Set(e),a=n.filter(s=>!u.has(s));return[...r,...a]}return r}const c=e.filter(o=>!n.some(r=>t(o,r)));if(i){const o=n.filter(r=>!e.some(u=>t(r,u)));return[...c,...o]}return c}function p(e,n){return e.filter(n)}function g(e,n){e.forEach(n)}function h(e,n){return e.join(n)}function y(e,n){return e.map(n)}function C(e,n){return[...e].sort(n)}function m(e){return Array.isArray(e)}function b(e){return typeof e=="bigint"}function d(e){return typeof e=="boolean"}function w(e){return e instanceof Date}function A(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 U(e){return typeof e=="object"&&e!==null&&Object.isFrozen(e)}function z(e){return typeof e=="function"}function L(e){return typeof e=="number"&&!Number.isNaN(e)}function S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _(e){return typeof e=="string"}function M(e){return typeof e=="symbol"}function $(e){return!!e}function N(e){return e===void 0}function O(e,n){return e+n}function D(e){return Math.ceil(e)}function E(e,n,t){return Math.min(Math.max(e,n),t)}function F(e,n){return e/n}function Z(e){return Math.floor(e)}function k(e,n){return e*n}function v(e){return Math.round(e)}function x(e,n){return e-n}function B(e){return Object.freeze(e)}function T(e,n){return{...e,...n}}function I(e,n,t){return e.slice(n,t)}function K(e,n,t){return e.split(n,t)}function P(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(n,t)=>t?t.toUpperCase():"").replace(/^[A-Z]/,n=>n.toLowerCase())}function q(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function G(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function H(e){return e.toLowerCase()}function J(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(n,t)=>t?t.toUpperCase():"").replace(/^[a-z]/,n=>n.toUpperCase())}function Q(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function R(e){return e.length===0?e:e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/[\s_]+/g,"-").replace(/^-+|-+$/g,"").replace(/-+/g,"-")}function V(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function W(e){return e.length===0?e:e.toLowerCase().replace(/(?:^|\s|-|_)\w/g,n=>n.toUpperCase())}function X(e){return e.toUpperCase()}function Y(e,n,t="..."){return e.length<=n?e:n-t.length<=0?t.slice(0,n):e.slice(0,n-t.length)+t}export{O as add,D as ceil,E as clamp,l as difference,F as divide,p as filter,Z as floor,g as forEach,B as freeze,m as isArray,b as isBigInt,d as isBoolean,w as isDate,A as isDefined,j as isEmpty,U as isFreeze,z as isFunction,L as isNumber,S as isObject,_ as isString,M as isSymbol,$ as isTruthy,N as isUndefined,h as join,y as map,T as merge,k as multiply,v as round,I as slice,C as sort,K as split,x as subtract,P as toCamelCase,q as toCapitalize,G as toKebabCase,H as toLowerCase,J as toPascalCase,Q as toSentenceCase,R as toSlug,V as toSnakeCase,W as toTitleCase,X as toUpperCase,Y as truncate};
package/dist/index.js CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";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),c=t.filter(f=>!i.has(f));return[...r,...c]}return r}const s=e.filter(o=>!t.some(r=>n(o,r)));if(u){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 b(e){return typeof e=="bigint"}function d(e){return typeof e=="boolean"}function w(e){return e instanceof Date}function A(e){return e!=null}function S(e){return e==null?!0:typeof e=="string"||Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}function j(e){return typeof e=="object"&&e!==null&&Object.isFrozen(e)}function z(e){return typeof e=="function"}function U(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 M(e,t){return e+t}function N(e){return Math.ceil(e)}function O(e,t,n){return Math.min(Math.max(e,t),n)}function $(e,t){return e/t}function B(e){return Math.floor(e)}function T(e,t){return e*t}function k(e){return Math.round(e)}function v(e,t){return e-t}function Z(e){return Object.freeze(e)}function I(e,t){return{...e,...t}}function K(e,t,n){return e.slice(t,n)}function P(e,t,n){return e.split(t,n)}function x(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase())}function q(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function G(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function H(e){return e.toLowerCase()}function J(e){return e.length===0?e:e.replace(/[-_\s]+(.)?/g,(t,n)=>n?n.toUpperCase():"").replace(/^[a-z]/,t=>t.toUpperCase())}function Q(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function R(e){return e.length===0?e:e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/[\s_]+/g,"-").replace(/^-+|-+$/g,"").replace(/-+/g,"-")}function V(e){return e.length===0?e:e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function W(e){return e.length===0?e:e.toLowerCase().replace(/(?:^|\s|-|_)\w/g,t=>t.toUpperCase())}function X(e){return e.toUpperCase()}function Y(e,t,n="..."){return e.length<=t?e:t-n.length<=0?n.slice(0,t):e.slice(0,t-n.length)+n}exports.add=M,exports.ceil=N,exports.clamp=O,exports.difference=l,exports.divide=$,exports.filter=p,exports.floor=B,exports.forEach=g,exports.freeze=Z,exports.isArray=m,exports.isBigInt=b,exports.isBoolean=d,exports.isDate=w,exports.isDefined=A,exports.isEmpty=S,exports.isFreeze=j,exports.isFunction=z,exports.isNumber=U,exports.isObject=L,exports.isString=_,exports.isSymbol=D,exports.isTruthy=E,exports.isUndefined=F,exports.join=C,exports.map=h,exports.merge=I,exports.multiply=T,exports.round=k,exports.slice=K,exports.sort=y,exports.split=P,exports.subtract=v,exports.toCamelCase=x,exports.toCapitalize=q,exports.toKebabCase=G,exports.toLowerCase=H,exports.toPascalCase=J,exports.toSentenceCase=Q,exports.toSlug=R,exports.toSnakeCase=V,exports.toTitleCase=W,exports.toUpperCase=X,exports.truncate=Y;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pistachiojs/core",
3
- "description": "Framework-agnostic TypeScript utility library with pure functions for common programming tasks",
4
- "version": "0.2.0-dev.2",
3
+ "description": "A TypeScript utility library with pure functions for common programming tasks",
4
+ "version": "0.3.0-dev.0",
5
5
  "author": "Dirga Prakesha <dirga.prakesha@gmail.com>",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -9,9 +9,6 @@
9
9
  "url": "https://github.com/dirgaprksha/pistachio.git",
10
10
  "directory": "packages/core"
11
11
  },
12
- "bugs": {
13
- "url": "https://github.com/dirgaprksha/pistachio/issues"
14
- },
15
12
  "keywords": [
16
13
  "utility",
17
14
  "typescript",
@@ -20,8 +17,7 @@
20
17
  "functional",
21
18
  "framework-agnostic",
22
19
  "type-safe",
23
- "tree-shakeable",
24
- "zero-dependencies"
20
+ "tree-shakeable"
25
21
  ],
26
22
  "sideEffects": false,
27
23
  "main": "dist/index.js",