@design-edito/tools 0.0.29 → 0.0.30

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.
@@ -1 +1 @@
1
- import{b as o}from"./chunk-SL2VL6LV.js";function f(r){return typeof r=="boolean"?r:typeof r=="string"?r.toLowerCase().trim()==="true":!o(r)}function e(r){return typeof r=="number"?r:typeof r=="string"?parseFloat(r):0}function c(r){return typeof r=="string"?r:String(r)}function p(r){return null}function u(r){return Array.isArray(r)?r:typeof r=="object"&&r!==null?Object.entries(r).map((t,n)=>({key:t,value:n})):[r]}function s(r){return u(r).map(n=>e(n))}function y(r){let t={};try{Object.keys(r).forEach(n=>{t[n]=r[n]})}catch{return t}return t}export{f as a,e as b,c,p as d,u as e,s as f,y as g};
1
+ import{d as o}from"./chunk-XCKXCF4A.js";function f(r){return typeof r=="boolean"?r:typeof r=="string"?r.toLowerCase().trim()==="true":!o(r)}function e(r){return typeof r=="number"?r:typeof r=="string"?parseFloat(r):0}function c(r){return typeof r=="string"?r:String(r)}function p(r){return null}function u(r){return Array.isArray(r)?r:typeof r=="object"&&r!==null?Object.entries(r).map((t,n)=>({key:t,value:n})):[r]}function s(r){return u(r).map(n=>e(n))}function y(r){let t={};try{Object.keys(r).forEach(n=>{t[n]=r[n]})}catch{return t}return t}export{f as a,e as b,c,p as d,u as e,s as f,y as g};
@@ -0,0 +1 @@
1
+ import{a as s}from"./chunk-ZVJO36JU.js";var t=[...s,!1,"",0,-0,NaN];typeof BigInt=="function"&&t.push(BigInt(0));function a(l){return t.includes(l)}function o(l){return!a(l)}var u=a;export{t as a,a as b,o as c,u as d};
@@ -0,0 +1 @@
1
+ var e=[null,void 0];function u(l){return e.includes(l)}function i(l){return!u(l)}var n=u;export{e as a,u as b,i as c,n as d};
package/index.js CHANGED
@@ -39,6 +39,7 @@ import * as getCurrentDownlink from './utils/browser/get-current-downlink/index.
39
39
  import * as getNodeAncestors from './utils/browser/get-node-ancestors/index.js'
40
40
  import * as isInDirectory from './utils/node/is-in-directory/index.js'
41
41
  import * as listSubpaths from './utils/node/list-subpaths/index.js'
42
+ import * as processExit from './utils/node/process-exit/index.js'
42
43
  import * as readWriteFile from './utils/node/read-write-file/index.js'
43
44
  export { Comp }
44
45
  export { absoluteModulo }
@@ -81,4 +82,5 @@ export { getCurrentDownlink }
81
82
  export { getNodeAncestors }
82
83
  export { isInDirectory }
83
84
  export { listSubpaths }
85
+ export { processExit }
84
86
  export { readWriteFile }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design-edito/tools",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",
@@ -1 +1 @@
1
- import{b as c}from"../../../chunks/chunk-WZBNXYN3.js";import{b as h}from"../../../chunks/chunk-SL2VL6LV.js";import"../../../chunks/chunk-PMZGSBLC.js";function r(e){let i=[];return typeof e=="string"?e.trim().split(/\s+/gm).forEach(t=>{c(t)&&i.push(t)}):Array.isArray(e)?e.forEach(t=>i.push(...r(t))):typeof e=="object"&&e!==null&&Object.entries(e).forEach(([t,s])=>{h(s)||i.push(...r(t))}),i}var n=r;var o=class e{constructor(){this.findBlockByName=this.findBlockByName.bind(this),this.addBlock=this.addBlock.bind(this),this.addElement=this.addElement.bind(this),this.addModifier=this.addModifier.bind(this),this.copy=this.copy.bind(this),this.block=this.block.bind(this),this.element=this.element.bind(this),this.modifier=this.modifier.bind(this),this.blk=this.blk.bind(this),this.elt=this.elt.bind(this),this.mod=this.mod.bind(this),this.cp=this.cp.bind(this),this.addSingleBlock=this.addSingleBlock.bind(this),this.addSingleElement=this.addSingleElement.bind(this),this.addSingleModifier=this.addSingleModifier.bind(this),this.setCurrentBlockByName=this.setCurrentBlockByName.bind(this),this.createBlockByName=this.createBlockByName.bind(this),this.getCurrentBlock=this.getCurrentBlock.bind(this)}addBlock(i){return n(i).forEach(this.addSingleBlock),this}addElement(i){return n(i).forEach(this.addSingleElement),this}addModifier(i){return this.getCurrentBlock()===void 0?this:(n(i).forEach(this.addSingleModifier),this)}copy(){let i=new e;return this.blocks.forEach(t=>{i.addBlock(t.name),t.modifiers.forEach(i.addModifier)}),i}block(i){return this.copy().addBlock(i)}element(i){return this.copy().addElement(i)}modifier(i){return this.copy().addModifier(i)}blk(i){return this.block(i)}elt(i){return this.element(i)}mod(i){return this.modifier(i)}cp(){return this.copy()}get value(){return this.blocks.map(i=>[i.name,...i.modifiers.map(t=>`${i.name}_${t}`)].join(" ")).join(" ")}get val(){return this.value}blocks=[];findBlockByName(i){return this.blocks.find(t=>t.name===i)}addSingleBlock(i){if(this.findBlockByName(i)!==void 0)this.setCurrentBlockByName(i);else{let t=this.createBlockByName(i);this.blocks.push(t)}return this}addSingleElement(i){let t=this.getCurrentBlock();return t===void 0?this.addBlock(i):t.name=t.name+"__"+i,this}addSingleModifier(i){let t=this.getCurrentBlock();return t!==void 0&&t.modifiers.push(i),this}setCurrentBlockByName(i){let t=this.findBlockByName(i);if(t!==void 0){let s=this.blocks.indexOf(t);this.blocks=[...this.blocks.slice(0,s),...this.blocks.slice(s+1),t]}return this}createBlockByName(i){return{name:i,modifiers:[]}}getCurrentBlock(){return this.blocks.slice(-1)[0]}},d=o;function l(e){let i=new d;return e instanceof d?e.copy():i.addBlock(e)}var y=l;export{d as BEM,l as bem,y as default,n as getNamesArr};
1
+ import{b as c}from"../../../chunks/chunk-WZBNXYN3.js";import{d as h}from"../../../chunks/chunk-XCKXCF4A.js";import"../../../chunks/chunk-ZVJO36JU.js";function r(e){let i=[];return typeof e=="string"?e.trim().split(/\s+/gm).forEach(t=>{c(t)&&i.push(t)}):Array.isArray(e)?e.forEach(t=>i.push(...r(t))):typeof e=="object"&&e!==null&&Object.entries(e).forEach(([t,s])=>{h(s)||i.push(...r(t))}),i}var n=r;var o=class e{constructor(){this.findBlockByName=this.findBlockByName.bind(this),this.addBlock=this.addBlock.bind(this),this.addElement=this.addElement.bind(this),this.addModifier=this.addModifier.bind(this),this.copy=this.copy.bind(this),this.block=this.block.bind(this),this.element=this.element.bind(this),this.modifier=this.modifier.bind(this),this.blk=this.blk.bind(this),this.elt=this.elt.bind(this),this.mod=this.mod.bind(this),this.cp=this.cp.bind(this),this.addSingleBlock=this.addSingleBlock.bind(this),this.addSingleElement=this.addSingleElement.bind(this),this.addSingleModifier=this.addSingleModifier.bind(this),this.setCurrentBlockByName=this.setCurrentBlockByName.bind(this),this.createBlockByName=this.createBlockByName.bind(this),this.getCurrentBlock=this.getCurrentBlock.bind(this)}addBlock(i){return n(i).forEach(this.addSingleBlock),this}addElement(i){return n(i).forEach(this.addSingleElement),this}addModifier(i){return this.getCurrentBlock()===void 0?this:(n(i).forEach(this.addSingleModifier),this)}copy(){let i=new e;return this.blocks.forEach(t=>{i.addBlock(t.name),t.modifiers.forEach(i.addModifier)}),i}block(i){return this.copy().addBlock(i)}element(i){return this.copy().addElement(i)}modifier(i){return this.copy().addModifier(i)}blk(i){return this.block(i)}elt(i){return this.element(i)}mod(i){return this.modifier(i)}cp(){return this.copy()}get value(){return this.blocks.map(i=>[i.name,...i.modifiers.map(t=>`${i.name}_${t}`)].join(" ")).join(" ")}get val(){return this.value}blocks=[];findBlockByName(i){return this.blocks.find(t=>t.name===i)}addSingleBlock(i){if(this.findBlockByName(i)!==void 0)this.setCurrentBlockByName(i);else{let t=this.createBlockByName(i);this.blocks.push(t)}return this}addSingleElement(i){let t=this.getCurrentBlock();return t===void 0?this.addBlock(i):t.name=t.name+"__"+i,this}addSingleModifier(i){let t=this.getCurrentBlock();return t!==void 0&&t.modifiers.push(i),this}setCurrentBlockByName(i){let t=this.findBlockByName(i);if(t!==void 0){let s=this.blocks.indexOf(t);this.blocks=[...this.blocks.slice(0,s),...this.blocks.slice(s+1),t]}return this}createBlockByName(i){return{name:i,modifiers:[]}}getCurrentBlock(){return this.blocks.slice(-1)[0]}},d=o;function l(e){let i=new d;return e instanceof d?e.copy():i.addBlock(e)}var y=l;export{d as BEM,l as bem,y as default,n as getNamesArr};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g}from"../../../chunks/chunk-7MQW6NRB.js";import"../../../chunks/chunk-SL2VL6LV.js";import"../../../chunks/chunk-PMZGSBLC.js";export{e as toArray,a as toBoolean,d as toNull,b as toNumber,f as toNumberArr,g as toRecord,c as toString};
1
+ import{a,b,c,d,e,f,g}from"../../../chunks/chunk-BEZTX3QU.js";import"../../../chunks/chunk-XCKXCF4A.js";import"../../../chunks/chunk-ZVJO36JU.js";export{e as toArray,a as toBoolean,d as toNull,b as toNumber,f as toNumberArr,g as toRecord,c as toString};
@@ -1 +1 @@
1
- import{g as o}from"../../../chunks/chunk-7MQW6NRB.js";import"../../../chunks/chunk-SL2VL6LV.js";import"../../../chunks/chunk-PMZGSBLC.js";function f(r){try{let{entries:n,getOwnPropertyDescriptors:c}=Object,s=o(r),i=n(c(r)).filter(([t,u])=>typeof u.get=="function").map(([t])=>t),e={...s};return i.forEach(t=>{e[t]=r[t]}),e}catch{return{}}}export{f as default};
1
+ import{g as o}from"../../../chunks/chunk-BEZTX3QU.js";import"../../../chunks/chunk-XCKXCF4A.js";import"../../../chunks/chunk-ZVJO36JU.js";function f(r){try{let{entries:n,getOwnPropertyDescriptors:c}=Object,s=o(r),i=n(c(r)).filter(([t,u])=>typeof u.get=="function").map(([t])=>t),e={...s};return i.forEach(t=>{e[t]=r[t]}),e}catch{return{}}}export{f as default};
@@ -1,4 +1,8 @@
1
- declare const falsyValues: (string | number | bigint | boolean | null | undefined)[];
2
- declare const isFalsy: (val: any) => boolean;
1
+ import { Nullish } from '~/utils/agnostic/is-nullish';
2
+ export type Falsy = Nullish | false | '' | 0 | -0 | typeof NaN | 0n;
3
+ export type NotFalsy<T> = Exclude<T, Exclude<Falsy, number>>;
4
+ declare const falsyValues: Falsy[];
3
5
  export { falsyValues };
6
+ export declare function isFalsy<T>(val: T | Falsy): val is Falsy;
7
+ export declare function isNotFalsy<T>(val: T): val is NotFalsy<T>;
4
8
  export default isFalsy;
@@ -1 +1 @@
1
- import{a,b}from"../../../chunks/chunk-SL2VL6LV.js";import"../../../chunks/chunk-PMZGSBLC.js";export{b as default,a as falsyValues};
1
+ import{a,b,c,d}from"../../../chunks/chunk-XCKXCF4A.js";import"../../../chunks/chunk-ZVJO36JU.js";export{d as default,a as falsyValues,b as isFalsy,c as isNotFalsy};
@@ -1,4 +1,5 @@
1
- declare const nullishValues: (null | undefined)[];
2
- declare function isNullish(val: any): boolean;
3
- export { nullishValues };
1
+ export declare const nullishValues: (null | undefined)[];
2
+ export type Nullish = null | undefined;
3
+ export declare function isNullish<T>(val: T | Nullish): val is Nullish;
4
+ export declare function isNotNullish<T>(val: T): val is Exclude<T, Nullish>;
4
5
  export default isNullish;
@@ -1 +1 @@
1
- import{a,b}from"../../../chunks/chunk-PMZGSBLC.js";export{b as default,a as nullishValues};
1
+ import{a,b,c,d}from"../../../chunks/chunk-ZVJO36JU.js";export{d as default,c as isNotNullish,b as isNullish,a as nullishValues};
@@ -1 +1 @@
1
- function T(s,c){let t=c,o=[],n=0,l,e=null;function r(){e!==null&&(clearTimeout(e),e=null);let a=Date.now(),i=n+t-a;e=setTimeout(()=>{e=null,l=s(...o),n=a},i)??null}function m(...a){let u=Date.now();return o=a,u-n>=c?(l=s(...o),n=u,{returnValue:l,lastExecutedOn:n,delayMs:t,isCached:!1}):(e===null&&r(),{returnValue:l,lastExecutedOn:n,delayMs:t,isCached:!0})}function d(a){t=a,e!==null&&r()}return{throttled:m,setDelay:d}}function y(s,c){let t=c,o=[],n=0,l=0,e,r=null;function m(){typeof r=="number"&&(window.clearTimeout(r),r=null);let u=Date.now(),x=n+t-u;r=setTimeout(()=>{r=null,e=s(...o),l=u},x)??null}function d(...u){let i=Date.now();return o=u,i-n>=t?(n=i,e=s(...o),l=i,{returnValue:e,lastExecutedOn:l,delayMs:t,isCached:!1}):(n=i,m(),{returnValue:e,lastExecutedOn:l,delayMs:t,isCached:!0})}function a(u){t=u,r!==null&&m()}return{debounced:d,setDelay:a}}export{y as debounce,T as throttle};
1
+ function T(s,c){let t=c,o=[],n=0,l,e=null;function r(){e!==null&&(clearTimeout(e),e=null);let a=Date.now(),i=n+t-a;e=setTimeout(()=>{e=null,l=s(...o),n=a},i)??null}function m(...a){let u=Date.now();return o=a,u-n>=c?(l=s(...o),n=u,{returnValue:l,lastExecutedOn:n,delayMs:t,isCached:!1}):(e===null&&r(),{returnValue:l,lastExecutedOn:n,delayMs:t,isCached:!0})}function d(a){t=a,e!==null&&r()}return{throttled:m,setDelay:d}}function y(s,c){let t=c,o=[],n=0,l=0,e,r=null;function m(){typeof r=="number"&&(clearTimeout(r),r=null);let u=Date.now(),x=n+t-u;r=setTimeout(()=>{r=null,e=s(...o),l=u},x)??null}function d(...u){let i=Date.now();return o=u,i-n>=t?(n=i,e=s(...o),l=i,{returnValue:e,lastExecutedOn:l,delayMs:t,isCached:!1}):(n=i,m(),{returnValue:e,lastExecutedOn:l,delayMs:t,isCached:!0})}function a(u){t=u,r!==null&&m()}return{debounced:d,setDelay:a}}export{y as debounce,T as throttle};
@@ -0,0 +1,3 @@
1
+ export declare const forceExitEvents: string[];
2
+ export declare function beforeForcedExit(callback: () => void | Promise<void>): void;
3
+ export declare function beforeExit(callback: () => void | Promise<void>): void;
@@ -0,0 +1 @@
1
+ var i=["SIGINT","SIGTERM","uncaughtException"];function r(o){i.forEach(e=>process.on(e,o))}function t(o){process.on("beforeExit",o)}export{t as beforeExit,r as beforeForcedExit,i as forceExitEvents};
@@ -1 +0,0 @@
1
- var l=[null,void 0];function e(n){return l.includes(n)}var u=e;export{l as a,u as b};
@@ -1 +0,0 @@
1
- import{a as n}from"./chunk-PMZGSBLC.js";var e=[...n,!1,"",0,-0,NaN];window.BigInt!==void 0&&e.push(window.BigInt(0));var l=i=>e.includes(i);var o=l;export{e as a,o as b};