@clerc/utils 1.1.1 → 1.2.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.mts CHANGED
@@ -24,8 +24,10 @@ type CamelCase<S extends string> = S extends `${infer Head} ${infer Tail}` ? `${
24
24
  declare const looseIsArray: <T>(arr: any) => arr is readonly T[];
25
25
  declare const toArray: <T>(a: MaybeArray<T>) => T[];
26
26
  /**
27
- * Converts a dash- or space-separated string to camelCase. Not using regexp for
28
- * better performance, because this function is used in parser.
27
+ * Converts a dash- or space-separated string to camelCase.
28
+ *
29
+ * Not using regexp for better performance, because this function is used in
30
+ * parser.
29
31
  */
30
32
  declare function camelCase(str: string): string;
31
33
  declare function joinWithAnd(values: string[]): string;
@@ -35,5 +37,6 @@ declare const formatVersion: (v: string) => string;
35
37
  declare const isTruthy: <T>(item: T) => item is Exclude<T, false | null | undefined>;
36
38
  declare const objectIsEmpty: (obj: Record<string, any>) => boolean;
37
39
  declare const resolveValue: <T>(value: MaybeGetter<T>) => T;
40
+ declare const hasOwn: (obj: object, key: PropertyKey) => boolean;
38
41
  //#endregion
39
- export { CamelCase, DeepPrettify, IsAny, LiteralUnion, MaybeArray, MaybeGetter, PartialRequired, Prettify, RequireExactlyOne, RequireExactlyOneOrNone, ToArray, UnionToIntersection, camelCase, formatFlagName, formatVersion, isTruthy, joinWithAnd, kebabCase, looseIsArray, objectIsEmpty, resolveValue, toArray };
42
+ export { CamelCase, DeepPrettify, IsAny, LiteralUnion, MaybeArray, MaybeGetter, PartialRequired, Prettify, RequireExactlyOne, RequireExactlyOneOrNone, ToArray, UnionToIntersection, camelCase, formatFlagName, formatVersion, hasOwn, isTruthy, joinWithAnd, kebabCase, looseIsArray, objectIsEmpty, resolveValue, toArray };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- const e=e=>Array.isArray(e),t=e=>Array.isArray(e)?e:[e];function n(e){let t=Math.min(e.includes(`-`)?e.indexOf(`-`):1/0,e.includes(` `)?e.indexOf(` `):1/0);if(t===1/0)return e;let n=e.slice(0,t);for(let r=t;r<e.length;r++)if((e[r]===`-`||e[r]===` `)&&r+1<e.length){let t=e.charCodeAt(r+1);t>=97&&t<=122?(n+=String.fromCharCode(t-32),r++):(n+=e[r+1],r++)}else e[r]!==`-`&&e[r]!==` `&&(n+=e[r]);return n}function r(e){if(e.length===0)return``;if(e.length===1)return e[0];let t=e.pop();return`${e.join(`, `)} and ${t}`}const i=e=>e.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`),a=e=>e.length<=1?`-${e}`:`--${i(e)}`,o=e=>e.length===0?``:e.startsWith(`v`)?e:`v${e}`,s=Boolean,c=e=>Object.keys(e).length===0,l=e=>typeof e==`function`?e():e;export{n as camelCase,a as formatFlagName,o as formatVersion,s as isTruthy,r as joinWithAnd,i as kebabCase,e as looseIsArray,c as objectIsEmpty,l as resolveValue,t as toArray};
1
+ const e=e=>Array.isArray(e),t=e=>Array.isArray(e)?e:[e],n=new Map;function r(e){let t=n.get(e);if(t!==void 0)return t;let r=e.length,i=-1;for(let t=0;t<r;t++){let n=e.charCodeAt(t);if(n===45||n===32){i=t;break}}if(i===-1)return n.set(e,e),e;let a=e.slice(0,i);for(let t=i;t<r;t++){let n=e.charCodeAt(t);if((n===45||n===32)&&t+1<r){let n=e.charCodeAt(t+1);n>=97&&n<=122?(a+=String.fromCharCode(n-32),t++):(a+=e[t+1],t++)}else n!==45&&n!==32&&(a+=e[t])}return n.set(e,a),a}function i(e){if(e.length===0)return``;if(e.length===1)return e[0];let t=e.pop();return`${e.join(`, `)} and ${t}`}const a=e=>e.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`),o=e=>e.length<=1?`-${e}`:`--${a(e)}`,s=e=>e.length===0?``:e.startsWith(`v`)?e:`v${e}`,c=Boolean,l=e=>Object.keys(e).length===0,u=e=>typeof e==`function`?e():e,d=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);export{r as camelCase,o as formatFlagName,s as formatVersion,d as hasOwn,c as isTruthy,i as joinWithAnd,a as kebabCase,e as looseIsArray,l as objectIsEmpty,u as resolveValue,t as toArray};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/utils",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
5
  "type": "module",
6
6
  "description": "Clerc utils",