@tempots/std 0.15.0 → 0.16.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/array.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Compare, Maybe, Nothing, Primitive } from './domain';
2
-
3
2
  /**
4
3
  * Applies a function to each element of an array and returns a new array with the results.
5
4
  *
package/async-result.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u={notAsked:{type:"NotAsked"},loading(e=void 0){return{type:"Loading",previousValue:e}},success(e){return{type:"AsyncSuccess",value:e}},failure(e){return{type:"AsyncFailure",error:e}},isSuccess(e){return e.type==="AsyncSuccess"},isFailure(e){return e.type==="AsyncFailure"},isNotAsked(e){return e.type==="NotAsked"},isLoading(e){return e.type==="Loading"},getOrElse(e,s){return u.isSuccess(e)?e.value:s},getOrElseLazy(e,s){return u.isSuccess(e)?e.value:s()},getOrNull(e){return u.isSuccess(e)?e.value:null},getOrUndefined(e){return u.isSuccess(e)?e.value:void 0},getUnsafe:e=>{if(u.isSuccess(e))return e.value;throw u.isFailure(e)?e.error:new Error("Cannot get value from a not-asked or loading result")},match:(e,{success:s,failure:r,loading:t,notAsked:l=t})=>u.isSuccess(e)?s(e.value):u.isFailure(e)?r(e.error):u.isNotAsked(e)?l():t(e.previousValue),whenSuccess:(e,s)=>(u.isSuccess(e)&&s(e.value),e),whenFailure:(e,s)=>(u.isFailure(e)&&s(e.error),e),equals:(e,s,r={valueEquals:(t,l)=>t===l,errorEquals:(t,l)=>t===l})=>e.type==="AsyncSuccess"&&s.type==="AsyncSuccess"?r.valueEquals(e.value,s.value):e.type==="AsyncFailure"&&s.type==="AsyncFailure"?r.errorEquals(e.error,s.error):e.type==="Loading"&&s.type==="Loading"?r.valueEquals(e.previousValue,s.previousValue):e.type==="NotAsked"&&s.type==="NotAsked",all:e=>{const s=[];for(const r of e)if(u.isSuccess(r))s.push(r.value);else return r;return u.success(s)}};exports.AsyncResult=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u={notAsked:{type:"NotAsked"},loading(e=void 0){return{type:"Loading",previousValue:e}},success(e){return{type:"AsyncSuccess",value:e}},failure(e){return{type:"AsyncFailure",error:e}},isSuccess(e){return e.type==="AsyncSuccess"},isFailure(e){return e.type==="AsyncFailure"},isNotAsked(e){return e.type==="NotAsked"},isLoading(e){return e.type==="Loading"},getOrElse(e,s){return u.isSuccess(e)?e.value:s},getOrElseLazy(e,s){return u.isSuccess(e)?e.value:s()},getOrNull(e){return u.isSuccess(e)?e.value:null},getOrUndefined(e){return u.isSuccess(e)?e.value:void 0},getUnsafe:e=>{if(u.isSuccess(e))return e.value;throw u.isFailure(e)?e.error:new Error("Cannot get value from a not-asked or loading result")},match:(e,{success:s,failure:r,loading:t,notAsked:n=t})=>u.isSuccess(e)?s(e.value):u.isFailure(e)?r(e.error):u.isNotAsked(e)?n():t(e.previousValue),whenSuccess:(e,s)=>(u.isSuccess(e)&&s(e.value),e),whenFailure:(e,s)=>(u.isFailure(e)&&s(e.error),e),equals:(e,s,r={valueEquals:(t,n)=>t===n,errorEquals:(t,n)=>t===n})=>e.type==="AsyncSuccess"&&s.type==="AsyncSuccess"?r.valueEquals(e.value,s.value):e.type==="AsyncFailure"&&s.type==="AsyncFailure"?r.errorEquals(e.error,s.error):e.type==="Loading"&&s.type==="Loading"?r.valueEquals(e.previousValue,s.previousValue):e.type==="NotAsked"&&s.type==="NotAsked",all:e=>{const s=[];for(const r of e)if(u.isSuccess(r))s.push(r.value);else return r;return u.success(s)},ofPromise:async e=>{try{const s=await e;return u.success(s)}catch(s){return u.failure(s instanceof Error?s:new Error(String(s)))}}};exports.AsyncResult=u;
package/async-result.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Maybe } from './domain';
2
-
3
2
  /**
4
3
  * Represents the state when a result has not been requested yet.
5
4
  * @public
@@ -195,4 +194,10 @@ export declare const AsyncResult: {
195
194
  * @returns A single result that is a success if all the input results are successes, otherwise a failure.
196
195
  */
197
196
  all: <V, E>(results: AsyncResult<V, E>[]) => AsyncResult<V[], E>;
197
+ /**
198
+ * Converts a Promise to an AsyncResult.
199
+ * @param p - The Promise to convert.
200
+ * @returns A Promise that resolves to an AsyncResult.
201
+ */
202
+ ofPromise: <V>(p: Promise<V>) => Promise<AsyncResult<V, Error>>;
198
203
  };
package/async-result.js CHANGED
@@ -131,8 +131,8 @@ const u = {
131
131
  success: s,
132
132
  failure: r,
133
133
  loading: t,
134
- notAsked: l = t
135
- }) => u.isSuccess(e) ? s(e.value) : u.isFailure(e) ? r(e.error) : u.isNotAsked(e) ? l() : t(e.previousValue),
134
+ notAsked: n = t
135
+ }) => u.isSuccess(e) ? s(e.value) : u.isFailure(e) ? r(e.error) : u.isNotAsked(e) ? n() : t(e.previousValue),
136
136
  /**
137
137
  * When the result is a success, it applies the function to the value.
138
138
  *
@@ -159,8 +159,8 @@ const u = {
159
159
  * @returns `true` if the results are equal, `false` otherwise.
160
160
  */
161
161
  equals: (e, s, r = {
162
- valueEquals: (t, l) => t === l,
163
- errorEquals: (t, l) => t === l
162
+ valueEquals: (t, n) => t === n,
163
+ errorEquals: (t, n) => t === n
164
164
  }) => e.type === "AsyncSuccess" && s.type === "AsyncSuccess" ? r.valueEquals(e.value, s.value) : e.type === "AsyncFailure" && s.type === "AsyncFailure" ? r.errorEquals(e.error, s.error) : e.type === "Loading" && s.type === "Loading" ? r.valueEquals(e.previousValue, s.previousValue) : e.type === "NotAsked" && s.type === "NotAsked",
165
165
  /**
166
166
  * Combines multiple results into a single result.
@@ -175,6 +175,19 @@ const u = {
175
175
  else
176
176
  return r;
177
177
  return u.success(s);
178
+ },
179
+ /**
180
+ * Converts a Promise to an AsyncResult.
181
+ * @param p - The Promise to convert.
182
+ * @returns A Promise that resolves to an AsyncResult.
183
+ */
184
+ ofPromise: async (e) => {
185
+ try {
186
+ const s = await e;
187
+ return u.success(s);
188
+ } catch (s) {
189
+ return u.failure(s instanceof Error ? s : new Error(String(s)));
190
+ }
178
191
  }
179
192
  };
180
193
  export {
package/domain.d.ts CHANGED
@@ -164,3 +164,19 @@ export type SplitLiteral<T extends string, SplitBy extends string> = FilterTuple
164
164
  * @public
165
165
  */
166
166
  export type SplitLiteralToUnion<T extends string, SplitBy extends string> = TupleToUnion<SplitLiteral<T, SplitBy>>;
167
+ /**
168
+ * Creates a new type by making the specified key `K` of `T` optional.
169
+ * @typeParam T - The type to create a new type from.
170
+ * @typeParam K - The key of `T` to make optional.
171
+ * @returns A new type with the specified key made optional.
172
+ * @public
173
+ */
174
+ export type PartialBy<T, K extends keyof T> = Merge<Omit<T, K>, Partial<Pick<T, K>>>;
175
+ /**
176
+ * Creates a new type by making the specified key `K` of `T` required.
177
+ * @typeParam T - The type to create a new type from.
178
+ * @typeParam K - The key of `T` to make required.
179
+ * @returns A new type with the specified key made required.
180
+ * @public
181
+ */
182
+ export type RequiredBy<T, K extends keyof T> = Merge<Omit<T, K>, Required<Pick<T, K>>>;
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./array.cjs"),l=require("./async-result.cjs"),i=require("./bigint.cjs"),a=require("./equal.cjs"),n=require("./function.cjs"),t=require("./number.cjs"),s=require("./object.cjs"),c=require("./promise.cjs"),p=require("./regexp.cjs"),o=require("./result-CdwVhaAc.cjs"),e=require("./string.cjs");exports.allElements=r.allElements;exports.anyElement=r.anyElement;exports.applyArrayDiffOperations=r.applyArrayDiffOperations;exports.areArraysEqual=r.areArraysEqual;exports.arrayDiffOperations=r.arrayDiffOperations;exports.arrayHasValues=r.arrayHasValues;exports.arrayHead=r.arrayHead;exports.arrayOfIterableIterator=r.arrayOfIterableIterator;exports.arrayTail=r.arrayTail;exports.compareArrays=r.compareArrays;exports.concatArrays=r.concatArrays;exports.createFilledArray=r.createFilledArray;exports.filterArray=r.filterArray;exports.filterMapArray=r.filterMapArray;exports.filterNullsFromArray=r.filterNullsFromArray;exports.flatMapArray=r.flatMapArray;exports.flattenArray=r.flattenArray;exports.foldLeftArray=r.foldLeftArray;exports.forEachElement=r.forEachElement;exports.generateArray=r.generateArray;exports.generateSequenceArray=r.generateSequenceArray;exports.isArrayEmpty=r.isArrayEmpty;exports.joinArrayWithConjunction=r.joinArrayWithConjunction;exports.mapArray=r.mapArray;exports.rankArray=r.rankArray;exports.removeAllFromArray=r.removeAllFromArray;exports.removeAllFromArrayByPredicate=r.removeAllFromArrayByPredicate;exports.removeOneFromArray=r.removeOneFromArray;exports.removeOneFromArrayByPredicate=r.removeOneFromArrayByPredicate;exports.sortArray=r.sortArray;exports.uniqueByPrimitive=r.uniqueByPrimitive;exports.uniquePrimitives=r.uniquePrimitives;exports.AsyncResult=l.AsyncResult;exports.biAbs=i.biAbs;exports.biCeilDiv=i.biCeilDiv;exports.biCompare=i.biCompare;exports.biFloorDiv=i.biFloorDiv;exports.biGcd=i.biGcd;exports.biIsEven=i.biIsEven;exports.biIsNegative=i.biIsNegative;exports.biIsOdd=i.biIsOdd;exports.biIsOne=i.biIsOne;exports.biIsPositive=i.biIsPositive;exports.biIsPrime=i.biIsPrime;exports.biIsZero=i.biIsZero;exports.biLcm=i.biLcm;exports.biMax=i.biMax;exports.biMin=i.biMin;exports.biNextPrime=i.biNextPrime;exports.biPow=i.biPow;exports.biPrevPrime=i.biPrevPrime;exports.deepEqual=a.deepEqual;exports.looseEqual=a.looseEqual;exports.strictEqual=a.strictEqual;exports.curryLeft=n.curryLeft;exports.identity=n.identity;exports.memoize=n.memoize;exports.EPSILON=t.EPSILON;exports.angleDifference=t.angleDifference;exports.ceilTo=t.ceilTo;exports.clamp=t.clamp;exports.clampInt=t.clampInt;exports.clampSym=t.clampSym;exports.compareNumbers=t.compareNumbers;exports.floorTo=t.floorTo;exports.interpolate=t.interpolate;exports.interpolateAngle=t.interpolateAngle;exports.interpolateAngleCCW=t.interpolateAngleCCW;exports.interpolateAngleCW=t.interpolateAngleCW;exports.interpolateWidestAngle=t.interpolateWidestAngle;exports.nearEqualAngles=t.nearEqualAngles;exports.nearEquals=t.nearEquals;exports.nearZero=t.nearZero;exports.root=t.root;exports.roundTo=t.roundTo;exports.sign=t.sign;exports.toHex=t.toHex;exports.widestAngleDifference=t.widestAngleDifference;exports.wrap=t.wrap;exports.wrapCircular=t.wrapCircular;exports.isEmptyObject=s.isEmptyObject;exports.isObject=s.isObject;exports.mergeObjects=s.mergeObjects;exports.objectKeys=s.objectKeys;exports.removeObjectFields=s.removeObjectFields;exports.sameObjectKeys=s.sameObjectKeys;exports.sleep=c.sleep;exports.mapRegExp=p.mapRegExp;exports.Result=o.Result;exports.Validation=o.Validation;exports.canonicalizeNewlines=e.canonicalizeNewlines;exports.capitalize=e.capitalize;exports.capitalizeWords=e.capitalizeWords;exports.chunkString=e.chunkString;exports.collapseText=e.collapseText;exports.compareCaseInsensitive=e.compareCaseInsensitive;exports.compareStrings=e.compareStrings;exports.containsAllText=e.containsAllText;exports.containsAllTextCaseInsensitive=e.containsAllTextCaseInsensitive;exports.containsAnyText=e.containsAnyText;exports.containsAnyTextCaseInsensitive=e.containsAnyTextCaseInsensitive;exports.countStringOccurrences=e.countStringOccurrences;exports.dasherize=e.dasherize;exports.decodeBase64=e.decodeBase64;exports.deleteFirstFromString=e.deleteFirstFromString;exports.deleteStringAfter=e.deleteStringAfter;exports.deleteStringBefore=e.deleteStringBefore;exports.deleteSubstring=e.deleteSubstring;exports.ellipsis=e.ellipsis;exports.ellipsisMiddle=e.ellipsisMiddle;exports.encodeBase64=e.encodeBase64;exports.filterCharcodes=e.filterCharcodes;exports.filterChars=e.filterChars;exports.humanize=e.humanize;exports.ifEmptyString=e.ifEmptyString;exports.isAlpha=e.isAlpha;exports.isAlphaNum=e.isAlphaNum;exports.isBreakingWhitespace=e.isBreakingWhitespace;exports.isDigitsOnly=e.isDigitsOnly;exports.isEmptyString=e.isEmptyString;exports.isLowerCase=e.isLowerCase;exports.isSpaceAt=e.isSpaceAt;exports.isUpperCase=e.isUpperCase;exports.jsQuote=e.jsQuote;exports.lowerCaseFirst=e.lowerCaseFirst;exports.lpad=e.lpad;exports.mapChars=e.mapChars;exports.quote=e.quote;exports.randomString=e.randomString;exports.randomStringSequence=e.randomStringSequence;exports.randomStringSequenceBase64=e.randomStringSequenceBase64;exports.repeatString=e.repeatString;exports.replaceAll=e.replaceAll;exports.reverseString=e.reverseString;exports.rpad=e.rpad;exports.smartQuote=e.smartQuote;exports.splitStringOnFirst=e.splitStringOnFirst;exports.splitStringOnLast=e.splitStringOnLast;exports.splitStringOnce=e.splitStringOnce;exports.stringContains=e.stringContains;exports.stringEndsWith=e.stringEndsWith;exports.stringEndsWithAny=e.stringEndsWithAny;exports.stringHasContent=e.stringHasContent;exports.stringHashCode=e.stringHashCode;exports.stringStartsWith=e.stringStartsWith;exports.stringStartsWithAny=e.stringStartsWithAny;exports.stringToCharcodes=e.stringToCharcodes;exports.stringToChars=e.stringToChars;exports.stringsDifferAtIndex=e.stringsDifferAtIndex;exports.substringAfter=e.substringAfter;exports.substringAfterLast=e.substringAfterLast;exports.substringBefore=e.substringBefore;exports.substringBeforeLast=e.substringBeforeLast;exports.surroundString=e.surroundString;exports.textContainsCaseInsensitive=e.textContainsCaseInsensitive;exports.textEndsWithAnyCaseInsensitive=e.textEndsWithAnyCaseInsensitive;exports.textEndsWithCaseInsensitive=e.textEndsWithCaseInsensitive;exports.textStartsWithAnyCaseInsensitive=e.textStartsWithAnyCaseInsensitive;exports.textStartsWithCaseInsensitive=e.textStartsWithCaseInsensitive;exports.textToLines=e.textToLines;exports.trimChars=e.trimChars;exports.trimCharsLeft=e.trimCharsLeft;exports.trimCharsRight=e.trimCharsRight;exports.trimStringSlice=e.trimStringSlice;exports.underscore=e.underscore;exports.upperCaseFirst=e.upperCaseFirst;exports.wrapColumns=e.wrapColumns;exports.wrapLine=e.wrapLine;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./array.cjs"),c=require("./async-result.cjs"),i=require("./bigint.cjs"),a=require("./equal.cjs"),n=require("./function.cjs"),o=require("./json.cjs"),t=require("./number.cjs"),s=require("./object.cjs"),m=require("./promise.cjs"),p=require("./regexp.cjs"),l=require("./result-CdwVhaAc.cjs"),e=require("./string.cjs");exports.allElements=r.allElements;exports.anyElement=r.anyElement;exports.applyArrayDiffOperations=r.applyArrayDiffOperations;exports.areArraysEqual=r.areArraysEqual;exports.arrayDiffOperations=r.arrayDiffOperations;exports.arrayHasValues=r.arrayHasValues;exports.arrayHead=r.arrayHead;exports.arrayOfIterableIterator=r.arrayOfIterableIterator;exports.arrayTail=r.arrayTail;exports.compareArrays=r.compareArrays;exports.concatArrays=r.concatArrays;exports.createFilledArray=r.createFilledArray;exports.filterArray=r.filterArray;exports.filterMapArray=r.filterMapArray;exports.filterNullsFromArray=r.filterNullsFromArray;exports.flatMapArray=r.flatMapArray;exports.flattenArray=r.flattenArray;exports.foldLeftArray=r.foldLeftArray;exports.forEachElement=r.forEachElement;exports.generateArray=r.generateArray;exports.generateSequenceArray=r.generateSequenceArray;exports.isArrayEmpty=r.isArrayEmpty;exports.joinArrayWithConjunction=r.joinArrayWithConjunction;exports.mapArray=r.mapArray;exports.rankArray=r.rankArray;exports.removeAllFromArray=r.removeAllFromArray;exports.removeAllFromArrayByPredicate=r.removeAllFromArrayByPredicate;exports.removeOneFromArray=r.removeOneFromArray;exports.removeOneFromArrayByPredicate=r.removeOneFromArrayByPredicate;exports.sortArray=r.sortArray;exports.uniqueByPrimitive=r.uniqueByPrimitive;exports.uniquePrimitives=r.uniquePrimitives;exports.AsyncResult=c.AsyncResult;exports.biAbs=i.biAbs;exports.biCeilDiv=i.biCeilDiv;exports.biCompare=i.biCompare;exports.biFloorDiv=i.biFloorDiv;exports.biGcd=i.biGcd;exports.biIsEven=i.biIsEven;exports.biIsNegative=i.biIsNegative;exports.biIsOdd=i.biIsOdd;exports.biIsOne=i.biIsOne;exports.biIsPositive=i.biIsPositive;exports.biIsPrime=i.biIsPrime;exports.biIsZero=i.biIsZero;exports.biLcm=i.biLcm;exports.biMax=i.biMax;exports.biMin=i.biMin;exports.biNextPrime=i.biNextPrime;exports.biPow=i.biPow;exports.biPrevPrime=i.biPrevPrime;exports.deepEqual=a.deepEqual;exports.looseEqual=a.looseEqual;exports.strictEqual=a.strictEqual;exports.curryLeft=n.curryLeft;exports.identity=n.identity;exports.memoize=n.memoize;exports.isJSONArray=o.isJSONArray;exports.isJSONObject=o.isJSONObject;exports.isJSONPrimitive=o.isJSONPrimitive;exports.EPSILON=t.EPSILON;exports.angleDifference=t.angleDifference;exports.ceilTo=t.ceilTo;exports.clamp=t.clamp;exports.clampInt=t.clampInt;exports.clampSym=t.clampSym;exports.compareNumbers=t.compareNumbers;exports.floorTo=t.floorTo;exports.interpolate=t.interpolate;exports.interpolateAngle=t.interpolateAngle;exports.interpolateAngleCCW=t.interpolateAngleCCW;exports.interpolateAngleCW=t.interpolateAngleCW;exports.interpolateWidestAngle=t.interpolateWidestAngle;exports.nearEqualAngles=t.nearEqualAngles;exports.nearEquals=t.nearEquals;exports.nearZero=t.nearZero;exports.root=t.root;exports.roundTo=t.roundTo;exports.sign=t.sign;exports.toHex=t.toHex;exports.widestAngleDifference=t.widestAngleDifference;exports.wrap=t.wrap;exports.wrapCircular=t.wrapCircular;exports.isEmptyObject=s.isEmptyObject;exports.isObject=s.isObject;exports.mergeObjects=s.mergeObjects;exports.objectEntries=s.objectEntries;exports.objectFromEntries=s.objectFromEntries;exports.objectKeys=s.objectKeys;exports.objectValues=s.objectValues;exports.removeObjectFields=s.removeObjectFields;exports.sameObjectKeys=s.sameObjectKeys;exports.sleep=m.sleep;exports.mapRegExp=p.mapRegExp;exports.Result=l.Result;exports.Validation=l.Validation;exports.canonicalizeNewlines=e.canonicalizeNewlines;exports.capitalize=e.capitalize;exports.capitalizeWords=e.capitalizeWords;exports.chunkString=e.chunkString;exports.collapseText=e.collapseText;exports.compareCaseInsensitive=e.compareCaseInsensitive;exports.compareStrings=e.compareStrings;exports.containsAllText=e.containsAllText;exports.containsAllTextCaseInsensitive=e.containsAllTextCaseInsensitive;exports.containsAnyText=e.containsAnyText;exports.containsAnyTextCaseInsensitive=e.containsAnyTextCaseInsensitive;exports.countStringOccurrences=e.countStringOccurrences;exports.dasherize=e.dasherize;exports.decodeBase64=e.decodeBase64;exports.deleteFirstFromString=e.deleteFirstFromString;exports.deleteStringAfter=e.deleteStringAfter;exports.deleteStringBefore=e.deleteStringBefore;exports.deleteSubstring=e.deleteSubstring;exports.ellipsis=e.ellipsis;exports.ellipsisMiddle=e.ellipsisMiddle;exports.encodeBase64=e.encodeBase64;exports.filterCharcodes=e.filterCharcodes;exports.filterChars=e.filterChars;exports.humanize=e.humanize;exports.ifEmptyString=e.ifEmptyString;exports.isAlpha=e.isAlpha;exports.isAlphaNum=e.isAlphaNum;exports.isBreakingWhitespace=e.isBreakingWhitespace;exports.isDigitsOnly=e.isDigitsOnly;exports.isEmptyString=e.isEmptyString;exports.isLowerCase=e.isLowerCase;exports.isSpaceAt=e.isSpaceAt;exports.isUpperCase=e.isUpperCase;exports.jsQuote=e.jsQuote;exports.lowerCaseFirst=e.lowerCaseFirst;exports.lpad=e.lpad;exports.mapChars=e.mapChars;exports.quote=e.quote;exports.randomString=e.randomString;exports.randomStringSequence=e.randomStringSequence;exports.randomStringSequenceBase64=e.randomStringSequenceBase64;exports.repeatString=e.repeatString;exports.replaceAll=e.replaceAll;exports.reverseString=e.reverseString;exports.rpad=e.rpad;exports.smartQuote=e.smartQuote;exports.splitStringOnFirst=e.splitStringOnFirst;exports.splitStringOnLast=e.splitStringOnLast;exports.splitStringOnce=e.splitStringOnce;exports.stringContains=e.stringContains;exports.stringEndsWith=e.stringEndsWith;exports.stringEndsWithAny=e.stringEndsWithAny;exports.stringHasContent=e.stringHasContent;exports.stringHashCode=e.stringHashCode;exports.stringStartsWith=e.stringStartsWith;exports.stringStartsWithAny=e.stringStartsWithAny;exports.stringToCharcodes=e.stringToCharcodes;exports.stringToChars=e.stringToChars;exports.stringsDifferAtIndex=e.stringsDifferAtIndex;exports.substringAfter=e.substringAfter;exports.substringAfterLast=e.substringAfterLast;exports.substringBefore=e.substringBefore;exports.substringBeforeLast=e.substringBeforeLast;exports.surroundString=e.surroundString;exports.textContainsCaseInsensitive=e.textContainsCaseInsensitive;exports.textEndsWithAnyCaseInsensitive=e.textEndsWithAnyCaseInsensitive;exports.textEndsWithCaseInsensitive=e.textEndsWithCaseInsensitive;exports.textStartsWithAnyCaseInsensitive=e.textStartsWithAnyCaseInsensitive;exports.textStartsWithCaseInsensitive=e.textStartsWithCaseInsensitive;exports.textToLines=e.textToLines;exports.trimChars=e.trimChars;exports.trimCharsLeft=e.trimCharsLeft;exports.trimCharsRight=e.trimCharsRight;exports.trimStringSlice=e.trimStringSlice;exports.underscore=e.underscore;exports.upperCaseFirst=e.upperCaseFirst;exports.wrapColumns=e.wrapColumns;exports.wrapLine=e.wrapLine;
package/index.js CHANGED
@@ -1,181 +1,188 @@
1
- import { allElements as t, anyElement as i, applyArrayDiffOperations as a, areArraysEqual as s, arrayDiffOperations as n, arrayHasValues as o, arrayHead as l, arrayOfIterableIterator as p, arrayTail as m, compareArrays as c, concatArrays as g, createFilledArray as y, filterArray as A, filterMapArray as f, filterNullsFromArray as d, flatMapArray as u, flattenArray as b, foldLeftArray as C, forEachElement as S, generateArray as x, generateSequenceArray as h, isArrayEmpty as v, joinArrayWithConjunction as E, mapArray as I, rankArray as O, removeAllFromArray as W, removeAllFromArrayByPredicate as F, removeOneFromArray as q, removeOneFromArrayByPredicate as T, sortArray as L, uniqueByPrimitive as P, uniquePrimitives as B } from "./array.js";
2
- import { AsyncResult as w } from "./async-result.js";
3
- import { biAbs as N, biCeilDiv as z, biCompare as H, biFloorDiv as M, biGcd as R, biIsEven as k, biIsNegative as V, biIsOdd as K, biIsOne as Q, biIsPositive as Z, biIsPrime as G, biIsZero as U, biLcm as J, biMax as X, biMin as Y, biNextPrime as _, biPow as $, biPrevPrime as ee } from "./bigint.js";
4
- import { deepEqual as te, looseEqual as ie, strictEqual as ae } from "./equal.js";
1
+ import { allElements as t, anyElement as i, applyArrayDiffOperations as s, areArraysEqual as a, arrayDiffOperations as n, arrayHasValues as o, arrayHead as l, arrayOfIterableIterator as m, arrayTail as p, compareArrays as c, concatArrays as y, createFilledArray as g, filterArray as A, filterMapArray as f, filterNullsFromArray as d, flatMapArray as u, flattenArray as b, foldLeftArray as S, forEachElement as C, generateArray as x, generateSequenceArray as h, isArrayEmpty as v, joinArrayWithConjunction as E, mapArray as O, rankArray as I, removeAllFromArray as F, removeAllFromArrayByPredicate as W, removeOneFromArray as j, removeOneFromArrayByPredicate as q, sortArray as P, uniqueByPrimitive as T, uniquePrimitives as L } from "./array.js";
2
+ import { AsyncResult as N } from "./async-result.js";
3
+ import { biAbs as D, biCeilDiv as z, biCompare as H, biFloorDiv as M, biGcd as R, biIsEven as V, biIsNegative as k, biIsOdd as J, biIsOne as K, biIsPositive as Q, biIsPrime as Z, biIsZero as G, biLcm as U, biMax as X, biMin as Y, biNextPrime as _, biPow as $, biPrevPrime as ee } from "./bigint.js";
4
+ import { deepEqual as te, looseEqual as ie, strictEqual as se } from "./equal.js";
5
5
  import { curryLeft as ne, identity as oe, memoize as le } from "./function.js";
6
- import { EPSILON as me, angleDifference as ce, ceilTo as ge, clamp as ye, clampInt as Ae, clampSym as fe, compareNumbers as de, floorTo as ue, interpolate as be, interpolateAngle as Ce, interpolateAngleCCW as Se, interpolateAngleCW as xe, interpolateWidestAngle as he, nearEqualAngles as ve, nearEquals as Ee, nearZero as Ie, root as Oe, roundTo as We, sign as Fe, toHex as qe, widestAngleDifference as Te, wrap as Le, wrapCircular as Pe } from "./number.js";
7
- import { isEmptyObject as je, isObject as we, mergeObjects as De, objectKeys as Ne, removeObjectFields as ze, sameObjectKeys as He } from "./object.js";
8
- import { sleep as Re } from "./promise.js";
9
- import { mapRegExp as Ve } from "./regexp.js";
10
- import { R as Qe, V as Ze } from "./result-CGd0jCdl.js";
11
- import { canonicalizeNewlines as Ue, capitalize as Je, capitalizeWords as Xe, chunkString as Ye, collapseText as _e, compareCaseInsensitive as $e, compareStrings as er, containsAllText as rr, containsAllTextCaseInsensitive as tr, containsAnyText as ir, containsAnyTextCaseInsensitive as ar, countStringOccurrences as sr, dasherize as nr, decodeBase64 as or, deleteFirstFromString as lr, deleteStringAfter as pr, deleteStringBefore as mr, deleteSubstring as cr, ellipsis as gr, ellipsisMiddle as yr, encodeBase64 as Ar, filterCharcodes as fr, filterChars as dr, humanize as ur, ifEmptyString as br, isAlpha as Cr, isAlphaNum as Sr, isBreakingWhitespace as xr, isDigitsOnly as hr, isEmptyString as vr, isLowerCase as Er, isSpaceAt as Ir, isUpperCase as Or, jsQuote as Wr, lowerCaseFirst as Fr, lpad as qr, mapChars as Tr, quote as Lr, randomString as Pr, randomStringSequence as Br, randomStringSequenceBase64 as jr, repeatString as wr, replaceAll as Dr, reverseString as Nr, rpad as zr, smartQuote as Hr, splitStringOnFirst as Mr, splitStringOnLast as Rr, splitStringOnce as kr, stringContains as Vr, stringEndsWith as Kr, stringEndsWithAny as Qr, stringHasContent as Zr, stringHashCode as Gr, stringStartsWith as Ur, stringStartsWithAny as Jr, stringToCharcodes as Xr, stringToChars as Yr, stringsDifferAtIndex as _r, substringAfter as $r, substringAfterLast as et, substringBefore as rt, substringBeforeLast as tt, surroundString as it, textContainsCaseInsensitive as at, textEndsWithAnyCaseInsensitive as st, textEndsWithCaseInsensitive as nt, textStartsWithAnyCaseInsensitive as ot, textStartsWithCaseInsensitive as lt, textToLines as pt, trimChars as mt, trimCharsLeft as ct, trimCharsRight as gt, trimStringSlice as yt, underscore as At, upperCaseFirst as ft, wrapColumns as dt, wrapLine as ut } from "./string.js";
6
+ import { isJSONArray as pe, isJSONObject as ce, isJSONPrimitive as ye } from "./json.js";
7
+ import { EPSILON as Ae, angleDifference as fe, ceilTo as de, clamp as ue, clampInt as be, clampSym as Se, compareNumbers as Ce, floorTo as xe, interpolate as he, interpolateAngle as ve, interpolateAngleCCW as Ee, interpolateAngleCW as Oe, interpolateWidestAngle as Ie, nearEqualAngles as Fe, nearEquals as We, nearZero as je, root as qe, roundTo as Pe, sign as Te, toHex as Le, widestAngleDifference as Be, wrap as Ne, wrapCircular as we } from "./number.js";
8
+ import { isEmptyObject as ze, isObject as He, mergeObjects as Me, objectEntries as Re, objectFromEntries as Ve, objectKeys as ke, objectValues as Je, removeObjectFields as Ke, sameObjectKeys as Qe } from "./object.js";
9
+ import { sleep as Ge } from "./promise.js";
10
+ import { mapRegExp as Xe } from "./regexp.js";
11
+ import { R as _e, V as $e } from "./result-CGd0jCdl.js";
12
+ import { canonicalizeNewlines as rr, capitalize as tr, capitalizeWords as ir, chunkString as sr, collapseText as ar, compareCaseInsensitive as nr, compareStrings as or, containsAllText as lr, containsAllTextCaseInsensitive as mr, containsAnyText as pr, containsAnyTextCaseInsensitive as cr, countStringOccurrences as yr, dasherize as gr, decodeBase64 as Ar, deleteFirstFromString as fr, deleteStringAfter as dr, deleteStringBefore as ur, deleteSubstring as br, ellipsis as Sr, ellipsisMiddle as Cr, encodeBase64 as xr, filterCharcodes as hr, filterChars as vr, humanize as Er, ifEmptyString as Or, isAlpha as Ir, isAlphaNum as Fr, isBreakingWhitespace as Wr, isDigitsOnly as jr, isEmptyString as qr, isLowerCase as Pr, isSpaceAt as Tr, isUpperCase as Lr, jsQuote as Br, lowerCaseFirst as Nr, lpad as wr, mapChars as Dr, quote as zr, randomString as Hr, randomStringSequence as Mr, randomStringSequenceBase64 as Rr, repeatString as Vr, replaceAll as kr, reverseString as Jr, rpad as Kr, smartQuote as Qr, splitStringOnFirst as Zr, splitStringOnLast as Gr, splitStringOnce as Ur, stringContains as Xr, stringEndsWith as Yr, stringEndsWithAny as _r, stringHasContent as $r, stringHashCode as et, stringStartsWith as rt, stringStartsWithAny as tt, stringToCharcodes as it, stringToChars as st, stringsDifferAtIndex as at, substringAfter as nt, substringAfterLast as ot, substringBefore as lt, substringBeforeLast as mt, surroundString as pt, textContainsCaseInsensitive as ct, textEndsWithAnyCaseInsensitive as yt, textEndsWithCaseInsensitive as gt, textStartsWithAnyCaseInsensitive as At, textStartsWithCaseInsensitive as ft, textToLines as dt, trimChars as ut, trimCharsLeft as bt, trimCharsRight as St, trimStringSlice as Ct, underscore as xt, upperCaseFirst as ht, wrapColumns as vt, wrapLine as Et } from "./string.js";
12
13
  export {
13
- w as AsyncResult,
14
- me as EPSILON,
15
- Qe as Result,
16
- Ze as Validation,
14
+ N as AsyncResult,
15
+ Ae as EPSILON,
16
+ _e as Result,
17
+ $e as Validation,
17
18
  t as allElements,
18
- ce as angleDifference,
19
+ fe as angleDifference,
19
20
  i as anyElement,
20
- a as applyArrayDiffOperations,
21
- s as areArraysEqual,
21
+ s as applyArrayDiffOperations,
22
+ a as areArraysEqual,
22
23
  n as arrayDiffOperations,
23
24
  o as arrayHasValues,
24
25
  l as arrayHead,
25
- p as arrayOfIterableIterator,
26
- m as arrayTail,
27
- N as biAbs,
26
+ m as arrayOfIterableIterator,
27
+ p as arrayTail,
28
+ D as biAbs,
28
29
  z as biCeilDiv,
29
30
  H as biCompare,
30
31
  M as biFloorDiv,
31
32
  R as biGcd,
32
- k as biIsEven,
33
- V as biIsNegative,
34
- K as biIsOdd,
35
- Q as biIsOne,
36
- Z as biIsPositive,
37
- G as biIsPrime,
38
- U as biIsZero,
39
- J as biLcm,
33
+ V as biIsEven,
34
+ k as biIsNegative,
35
+ J as biIsOdd,
36
+ K as biIsOne,
37
+ Q as biIsPositive,
38
+ Z as biIsPrime,
39
+ G as biIsZero,
40
+ U as biLcm,
40
41
  X as biMax,
41
42
  Y as biMin,
42
43
  _ as biNextPrime,
43
44
  $ as biPow,
44
45
  ee as biPrevPrime,
45
- Ue as canonicalizeNewlines,
46
- Je as capitalize,
47
- Xe as capitalizeWords,
48
- ge as ceilTo,
49
- Ye as chunkString,
50
- ye as clamp,
51
- Ae as clampInt,
52
- fe as clampSym,
53
- _e as collapseText,
46
+ rr as canonicalizeNewlines,
47
+ tr as capitalize,
48
+ ir as capitalizeWords,
49
+ de as ceilTo,
50
+ sr as chunkString,
51
+ ue as clamp,
52
+ be as clampInt,
53
+ Se as clampSym,
54
+ ar as collapseText,
54
55
  c as compareArrays,
55
- $e as compareCaseInsensitive,
56
- de as compareNumbers,
57
- er as compareStrings,
58
- g as concatArrays,
59
- rr as containsAllText,
60
- tr as containsAllTextCaseInsensitive,
61
- ir as containsAnyText,
62
- ar as containsAnyTextCaseInsensitive,
63
- sr as countStringOccurrences,
64
- y as createFilledArray,
56
+ nr as compareCaseInsensitive,
57
+ Ce as compareNumbers,
58
+ or as compareStrings,
59
+ y as concatArrays,
60
+ lr as containsAllText,
61
+ mr as containsAllTextCaseInsensitive,
62
+ pr as containsAnyText,
63
+ cr as containsAnyTextCaseInsensitive,
64
+ yr as countStringOccurrences,
65
+ g as createFilledArray,
65
66
  ne as curryLeft,
66
- nr as dasherize,
67
- or as decodeBase64,
67
+ gr as dasherize,
68
+ Ar as decodeBase64,
68
69
  te as deepEqual,
69
- lr as deleteFirstFromString,
70
- pr as deleteStringAfter,
71
- mr as deleteStringBefore,
72
- cr as deleteSubstring,
73
- gr as ellipsis,
74
- yr as ellipsisMiddle,
75
- Ar as encodeBase64,
70
+ fr as deleteFirstFromString,
71
+ dr as deleteStringAfter,
72
+ ur as deleteStringBefore,
73
+ br as deleteSubstring,
74
+ Sr as ellipsis,
75
+ Cr as ellipsisMiddle,
76
+ xr as encodeBase64,
76
77
  A as filterArray,
77
- fr as filterCharcodes,
78
- dr as filterChars,
78
+ hr as filterCharcodes,
79
+ vr as filterChars,
79
80
  f as filterMapArray,
80
81
  d as filterNullsFromArray,
81
82
  u as flatMapArray,
82
83
  b as flattenArray,
83
- ue as floorTo,
84
- C as foldLeftArray,
85
- S as forEachElement,
84
+ xe as floorTo,
85
+ S as foldLeftArray,
86
+ C as forEachElement,
86
87
  x as generateArray,
87
88
  h as generateSequenceArray,
88
- ur as humanize,
89
+ Er as humanize,
89
90
  oe as identity,
90
- br as ifEmptyString,
91
- be as interpolate,
92
- Ce as interpolateAngle,
93
- Se as interpolateAngleCCW,
94
- xe as interpolateAngleCW,
95
- he as interpolateWidestAngle,
96
- Cr as isAlpha,
97
- Sr as isAlphaNum,
91
+ Or as ifEmptyString,
92
+ he as interpolate,
93
+ ve as interpolateAngle,
94
+ Ee as interpolateAngleCCW,
95
+ Oe as interpolateAngleCW,
96
+ Ie as interpolateWidestAngle,
97
+ Ir as isAlpha,
98
+ Fr as isAlphaNum,
98
99
  v as isArrayEmpty,
99
- xr as isBreakingWhitespace,
100
- hr as isDigitsOnly,
101
- je as isEmptyObject,
102
- vr as isEmptyString,
103
- Er as isLowerCase,
104
- we as isObject,
105
- Ir as isSpaceAt,
106
- Or as isUpperCase,
100
+ Wr as isBreakingWhitespace,
101
+ jr as isDigitsOnly,
102
+ ze as isEmptyObject,
103
+ qr as isEmptyString,
104
+ pe as isJSONArray,
105
+ ce as isJSONObject,
106
+ ye as isJSONPrimitive,
107
+ Pr as isLowerCase,
108
+ He as isObject,
109
+ Tr as isSpaceAt,
110
+ Lr as isUpperCase,
107
111
  E as joinArrayWithConjunction,
108
- Wr as jsQuote,
112
+ Br as jsQuote,
109
113
  ie as looseEqual,
110
- Fr as lowerCaseFirst,
111
- qr as lpad,
112
- I as mapArray,
113
- Tr as mapChars,
114
- Ve as mapRegExp,
114
+ Nr as lowerCaseFirst,
115
+ wr as lpad,
116
+ O as mapArray,
117
+ Dr as mapChars,
118
+ Xe as mapRegExp,
115
119
  le as memoize,
116
- De as mergeObjects,
117
- ve as nearEqualAngles,
118
- Ee as nearEquals,
119
- Ie as nearZero,
120
- Ne as objectKeys,
121
- Lr as quote,
122
- Pr as randomString,
123
- Br as randomStringSequence,
124
- jr as randomStringSequenceBase64,
125
- O as rankArray,
126
- W as removeAllFromArray,
127
- F as removeAllFromArrayByPredicate,
128
- ze as removeObjectFields,
129
- q as removeOneFromArray,
130
- T as removeOneFromArrayByPredicate,
131
- wr as repeatString,
132
- Dr as replaceAll,
133
- Nr as reverseString,
134
- Oe as root,
135
- We as roundTo,
136
- zr as rpad,
137
- He as sameObjectKeys,
138
- Fe as sign,
139
- Re as sleep,
140
- Hr as smartQuote,
141
- L as sortArray,
142
- Mr as splitStringOnFirst,
143
- Rr as splitStringOnLast,
144
- kr as splitStringOnce,
145
- ae as strictEqual,
146
- Vr as stringContains,
147
- Kr as stringEndsWith,
148
- Qr as stringEndsWithAny,
149
- Zr as stringHasContent,
150
- Gr as stringHashCode,
151
- Ur as stringStartsWith,
152
- Jr as stringStartsWithAny,
153
- Xr as stringToCharcodes,
154
- Yr as stringToChars,
155
- _r as stringsDifferAtIndex,
156
- $r as substringAfter,
157
- et as substringAfterLast,
158
- rt as substringBefore,
159
- tt as substringBeforeLast,
160
- it as surroundString,
161
- at as textContainsCaseInsensitive,
162
- st as textEndsWithAnyCaseInsensitive,
163
- nt as textEndsWithCaseInsensitive,
164
- ot as textStartsWithAnyCaseInsensitive,
165
- lt as textStartsWithCaseInsensitive,
166
- pt as textToLines,
167
- qe as toHex,
168
- mt as trimChars,
169
- ct as trimCharsLeft,
170
- gt as trimCharsRight,
171
- yt as trimStringSlice,
172
- At as underscore,
173
- P as uniqueByPrimitive,
174
- B as uniquePrimitives,
175
- ft as upperCaseFirst,
176
- Te as widestAngleDifference,
177
- Le as wrap,
178
- Pe as wrapCircular,
179
- dt as wrapColumns,
180
- ut as wrapLine
120
+ Me as mergeObjects,
121
+ Fe as nearEqualAngles,
122
+ We as nearEquals,
123
+ je as nearZero,
124
+ Re as objectEntries,
125
+ Ve as objectFromEntries,
126
+ ke as objectKeys,
127
+ Je as objectValues,
128
+ zr as quote,
129
+ Hr as randomString,
130
+ Mr as randomStringSequence,
131
+ Rr as randomStringSequenceBase64,
132
+ I as rankArray,
133
+ F as removeAllFromArray,
134
+ W as removeAllFromArrayByPredicate,
135
+ Ke as removeObjectFields,
136
+ j as removeOneFromArray,
137
+ q as removeOneFromArrayByPredicate,
138
+ Vr as repeatString,
139
+ kr as replaceAll,
140
+ Jr as reverseString,
141
+ qe as root,
142
+ Pe as roundTo,
143
+ Kr as rpad,
144
+ Qe as sameObjectKeys,
145
+ Te as sign,
146
+ Ge as sleep,
147
+ Qr as smartQuote,
148
+ P as sortArray,
149
+ Zr as splitStringOnFirst,
150
+ Gr as splitStringOnLast,
151
+ Ur as splitStringOnce,
152
+ se as strictEqual,
153
+ Xr as stringContains,
154
+ Yr as stringEndsWith,
155
+ _r as stringEndsWithAny,
156
+ $r as stringHasContent,
157
+ et as stringHashCode,
158
+ rt as stringStartsWith,
159
+ tt as stringStartsWithAny,
160
+ it as stringToCharcodes,
161
+ st as stringToChars,
162
+ at as stringsDifferAtIndex,
163
+ nt as substringAfter,
164
+ ot as substringAfterLast,
165
+ lt as substringBefore,
166
+ mt as substringBeforeLast,
167
+ pt as surroundString,
168
+ ct as textContainsCaseInsensitive,
169
+ yt as textEndsWithAnyCaseInsensitive,
170
+ gt as textEndsWithCaseInsensitive,
171
+ At as textStartsWithAnyCaseInsensitive,
172
+ ft as textStartsWithCaseInsensitive,
173
+ dt as textToLines,
174
+ Le as toHex,
175
+ ut as trimChars,
176
+ bt as trimCharsLeft,
177
+ St as trimCharsRight,
178
+ Ct as trimStringSlice,
179
+ xt as underscore,
180
+ T as uniqueByPrimitive,
181
+ L as uniquePrimitives,
182
+ ht as upperCaseFirst,
183
+ Be as widestAngleDifference,
184
+ Ne as wrap,
185
+ we as wrapCircular,
186
+ vt as wrapColumns,
187
+ Et as wrapLine
181
188
  };
package/json.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=r=>typeof r=="object"&&!Array.isArray(r)&&r!=null,i=r=>Array.isArray(r),o=r=>typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r==null;exports.isJSONArray=i;exports.isJSONObject=t;exports.isJSONPrimitive=o;
package/json.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Nothing } from './domain';
2
-
3
2
  /**
4
3
  * Represents a JSON primitive value.
5
4
  * It can be a string, boolean, number, or Nothing (null or undefined).
@@ -23,3 +22,27 @@ export type JSONArray = JSONValue[];
23
22
  * @public
24
23
  */
25
24
  export type JSONValue = JSONPrimitive | JSONObject | JSONArray;
25
+ /**
26
+ * Checks if the value is a JSON object.
27
+ *
28
+ * @param value - The value to check.
29
+ * @returns `true` if the value is a JSON object; otherwise, `false`.
30
+ * @public
31
+ */
32
+ export declare const isJSONObject: (value: JSONValue) => value is JSONObject;
33
+ /**
34
+ * Checks if the value is a JSON array.
35
+ *
36
+ * @param value - The value to check.
37
+ * @returns `true` if the value is a JSON array; otherwise, `false`.
38
+ * @public
39
+ */
40
+ export declare const isJSONArray: (value: JSONValue) => value is JSONArray;
41
+ /**
42
+ * Checks if the value is a JSON primitive.
43
+ *
44
+ * @param value - The value to check.
45
+ * @returns `true` if the value is a JSON primitive; otherwise, `false`.
46
+ * @public
47
+ */
48
+ export declare const isJSONPrimitive: (value: JSONValue) => value is JSONPrimitive;
package/json.js CHANGED
@@ -1 +1,6 @@
1
-
1
+ const t = (r) => typeof r == "object" && !Array.isArray(r) && r != null, o = (r) => Array.isArray(r), i = (r) => typeof r == "string" || typeof r == "boolean" || typeof r == "number" || r == null;
2
+ export {
3
+ o as isJSONArray,
4
+ t as isJSONObject,
5
+ i as isJSONPrimitive
6
+ };
package/object.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=e=>Object.keys(e),o=(e,t)=>{const r=n(e),c=n(t);if(r.length!==c.length)return!1;for(const s of r)if(!(s in t))return!1;return!0},b=e=>e!=null&&Object.getPrototypeOf(e)===Object.prototype,j=(e,...t)=>n(e).reduce((c,s)=>(t.includes(s)||(c[s]=e[s]),c),{}),O=(e,t)=>Object.assign({},e,t),i=e=>Object.keys(e).length===0;exports.isEmptyObject=i;exports.isObject=b;exports.mergeObjects=O;exports.objectKeys=n;exports.removeObjectFields=j;exports.sameObjectKeys=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=e=>Object.keys(e),r=e=>Object.values(e),b=e=>Object.entries(e),j=e=>Object.fromEntries(e),i=(e,t)=>{const n=o(e),c=o(t);if(n.length!==c.length)return!1;for(const s of n)if(!(s in t))return!1;return!0},O=e=>e!=null&&Object.getPrototypeOf(e)===Object.prototype,l=(e,...t)=>o(e).reduce((c,s)=>(t.includes(s)||(c[s]=e[s]),c),{}),u=(e,t)=>Object.assign({},e,t),m=e=>Object.keys(e).length===0;exports.isEmptyObject=m;exports.isObject=O;exports.mergeObjects=u;exports.objectEntries=b;exports.objectFromEntries=j;exports.objectKeys=o;exports.objectValues=r;exports.removeObjectFields=l;exports.sameObjectKeys=i;
package/object.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { IndexKey, Merge, TupleToUnion } from './domain';
2
-
3
2
  /**
4
3
  * Returns an array of keys from the given object.
5
4
  *
@@ -8,6 +7,30 @@ import { IndexKey, Merge, TupleToUnion } from './domain';
8
7
  * @public
9
8
  */
10
9
  export declare const objectKeys: <T extends object>(obj: T) => Array<keyof T>;
10
+ /**
11
+ * Returns an array of values from the given object.
12
+ *
13
+ * @param obj - The object from which to extract values.
14
+ * @returns An array of values from the object.
15
+ * @public
16
+ */
17
+ export declare const objectValues: <T extends object>(obj: T) => Array<T[keyof T]>;
18
+ /**
19
+ * Returns an array of entries (key-value pairs) from the given object.
20
+ *
21
+ * @param obj - The object from which to extract entries.
22
+ * @returns An array of tuples, where each tuple contains a key and its corresponding value from the object.
23
+ * @public
24
+ */
25
+ export declare const objectEntries: <T extends object>(obj: T) => [keyof T, T[keyof T]][];
26
+ /**
27
+ * Creates an object from an array of entries.
28
+ *
29
+ * @param entries - The array of entries to create an object from.
30
+ * @returns The created object.
31
+ * @public
32
+ */
33
+ export declare const objectFromEntries: <T extends object>(entries: [keyof T, T[keyof T]][]) => T;
11
34
  /**
12
35
  * Checks if two objects have the same keys.
13
36
  *
package/object.js CHANGED
@@ -1,15 +1,18 @@
1
- const r = (e) => Object.keys(e), o = (e, t) => {
2
- const c = r(e), n = r(t);
3
- if (c.length !== n.length) return !1;
4
- for (const s of c)
1
+ const o = (e) => Object.keys(e), r = (e) => Object.values(e), j = (e) => Object.entries(e), b = (e) => Object.fromEntries(e), O = (e, t) => {
2
+ const n = o(e), c = o(t);
3
+ if (n.length !== c.length) return !1;
4
+ for (const s of n)
5
5
  if (!(s in t)) return !1;
6
6
  return !0;
7
- }, O = (e) => e != null && Object.getPrototypeOf(e) === Object.prototype, j = (e, ...t) => r(e).reduce((n, s) => (t.includes(s) || (n[s] = e[s]), n), {}), b = (e, t) => Object.assign({}, e, t), i = (e) => Object.keys(e).length === 0;
7
+ }, i = (e) => e != null && Object.getPrototypeOf(e) === Object.prototype, l = (e, ...t) => o(e).reduce((c, s) => (t.includes(s) || (c[s] = e[s]), c), {}), u = (e, t) => Object.assign({}, e, t), f = (e) => Object.keys(e).length === 0;
8
8
  export {
9
- i as isEmptyObject,
10
- O as isObject,
11
- b as mergeObjects,
12
- r as objectKeys,
13
- j as removeObjectFields,
14
- o as sameObjectKeys
9
+ f as isEmptyObject,
10
+ i as isObject,
11
+ u as mergeObjects,
12
+ j as objectEntries,
13
+ b as objectFromEntries,
14
+ o as objectKeys,
15
+ r as objectValues,
16
+ l as removeObjectFields,
17
+ O as sameObjectKeys
15
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/std",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "priority": 8,
5
5
  "description": "Std library for TypeScript. Natural complement to the Tempo libraries.",
6
6
  "keywords": [
package/result.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { AsyncResult } from './async-result';
2
2
  import { Maybe } from './domain';
3
3
  import { Validation } from './validation';
4
-
5
4
  /**
6
5
  * Represents a successful result.
7
6
  * @typeParam V - The type of the value.
package/validation.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Result } from './result';
2
-
3
2
  /**
4
3
  * Represents a valid result.
5
4
  * @public