@design-edito/tools 0.0.32 → 0.0.33

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/index.js CHANGED
@@ -34,6 +34,7 @@ import * as selectorToElement from './utils/agnostic/selector-to-element/index.j
34
34
  import * as silentLog from './utils/agnostic/silent-log/index.js'
35
35
  import * as strToNodes from './utils/agnostic/str-to-nodes/index.js'
36
36
  import * as stringMatches from './utils/agnostic/string-matches/index.js'
37
+ import * as stringNormalizeIndent from './utils/agnostic/string-normalize-indent/index.js'
37
38
  import * as throttleDebounce from './utils/agnostic/throttle-debounce/index.js'
38
39
  import * as toAlphanum from './utils/agnostic/to-alphanum/index.js'
39
40
  import * as transition from './utils/agnostic/transition/index.js'
@@ -81,6 +82,7 @@ export { selectorToElement }
81
82
  export { silentLog }
82
83
  export { strToNodes }
83
84
  export { stringMatches }
85
+ export { stringNormalizeIndent }
84
86
  export { throttleDebounce }
85
87
  export { toAlphanum }
86
88
  export { transition }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design-edito/tools",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",
@@ -1 +1 @@
1
- export default function isInEnum<E extends Object>(enumObj: E, value: unknown): value is E[keyof E];
1
+ export default function isInEnum<E extends Record<string, string | number>>(enumObj: E, value: string | number): value is E[keyof E];
@@ -1 +1 @@
1
- function u(e,n){return Object.values(e).includes(n)}export{u as default};
1
+ function l(s,n){let t=Object.keys(s),c=Object.values(s).filter(e=>typeof e=="number");return t.filter(e=>!c.includes(parseInt(e,10))).map(e=>s[e]).includes(n)}export{l as default};
@@ -1,6 +1,11 @@
1
- type FuncRecord = Record<string, (...args: any[]) => any>;
2
- type UnwrapPromise<PromiseOrNot> = PromiseOrNot extends Promise<infer Resolved> ? Resolved : PromiseOrNot;
3
- export default function recordFormat<Format extends FuncRecord>(input: Record<string, unknown>, format: Format): Promise<{
4
- [Key in keyof Format]: UnwrapPromise<ReturnType<Format[Key]>>;
5
- }>;
6
- export {};
1
+ export type FormatKey<Input extends {} = any> = keyof Input | string;
2
+ export type InputValue<Input extends {}, Key extends FormatKey<Input>> = Input extends Record<Key, infer V> ? V : undefined;
3
+ export type FormatterFunc<I, O> = (val: I) => O | Promise<O>;
4
+ export type Format<Input extends {} = any> = {
5
+ [Key in FormatKey<Input>]: FormatterFunc<InputValue<Input, Key>, any>;
6
+ };
7
+ export type UnwrapPromise<PromiseOrNot> = PromiseOrNot extends Promise<infer Resolved> ? Resolved : PromiseOrNot;
8
+ export type Formatted<F extends Format<{}>> = {
9
+ [Key in keyof F]: UnwrapPromise<ReturnType<F[Key]>>;
10
+ };
11
+ export default function recordFormat<I extends {}, F extends Format<I>>(input: I, format: F): Promise<Formatted<F>>;
@@ -1 +1 @@
1
- async function y(n,s){let e={},r=[];return Object.entries(s).forEach(async([o,a])=>{let i=n[o],t=a(i);r.push(t);let m=await t;e[o]=m}),await Promise.all(r),e}export{y as default};
1
+ async function a(o,n){let t={};for(let e in n){let r=n[e];typeof r=="function"?t[e]=await r(o[e]):t[e]=r}return t}export{a as default};
@@ -0,0 +1 @@
1
+ export default function stringNormalizeIndent(input: string, indentLevel?: number): string;
@@ -0,0 +1,3 @@
1
+ function r(i,t=0){let s=" ".repeat(t);return i.split(`
2
+ `).map(e=>e.replace(/^\s*/igm,"")).map(e=>{let n=e.match(/^\|+/igm)?.[0].length??0,p=e.slice(n);return" ".repeat(n)+p}).map(e=>s+e).join(`
3
+ `)}export{r as default};