codsen-utils 1.3.1 → 1.5.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/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 1.5.0 (2023-05-13)
7
+
8
+ ### Bug Fixes
9
+
10
+ - type improvements ([6847c21](https://github.com/codsen/codsen/commit/6847c21ce33b36e56b767ef63504d9233810d2e9))
11
+ - type tweaks ([8173408](https://github.com/codsen/codsen/commit/8173408b57f963055cca991a0cb697c9d2d664e4))
12
+
13
+ ### Features
14
+
15
+ - add `compareFn()` to tackle `@typescript-eslint/require-array-sort-compare` lint rule ([a25524a](https://github.com/codsen/codsen/commit/a25524a027067208b8e94b30b6745790ec278fbe))
16
+ - add `includes()` ([c6cf14e](https://github.com/codsen/codsen/commit/c6cf14e8a7f3fb2a063fcec3381700798341ad42))
17
+
18
+ # [1.4.0](https://github.com/codsen/codsen/compare/codsen-utils@1.3.1...codsen-utils@1.4.0) (2023-04-16)
19
+
20
+ ### Features
21
+
22
+ - add `detectEol()` ([04d2f3d](https://github.com/codsen/codsen/commit/04d2f3d36963e1b1729887098126cba5719d97c0))
23
+ - add `resolveEolSetting()` and type `EolSetting` ([ceae282](https://github.com/codsen/codsen/commit/ceae282e1f9240638e0aefc57eab48dde9de6ba1))
24
+
6
25
  # [1.3.0](https://github.com/codsen/codsen/compare/codsen-utils@1.2.0...codsen-utils@1.3.0) (2023-03-12)
7
26
 
8
27
  ### Features
@@ -1,10 +1,19 @@
1
1
  /**
2
2
  * @name codsen-utils
3
3
  * @fileoverview Various utility functions
4
- * @version 1.3.1
4
+ * @version 1.5.0
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/codsen-utils/}
8
8
  */
9
9
 
10
- var s="1.3.1";var x=s,c="\u2018",u="\u2019",l="\u201C",a="\u201D",h="\u2013",g="\u2014",y="\xA0",w="\u2026",k="\u200A",C="\u2009",j="\u2032",S="\u2033",T="\\",A="\uFFFD",L="`",O="\xD7",$=[".",",",";","!","?"];function D(t){return n(t)&&t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57}function m(t){return n(t)&&"\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4".includes(t)}function R(t){let e=new Set(["$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]);return n(t)&&!!t.trim()&&(m(t)||e.has(t))}function i(t){return n(t)&&t.length===1&&t.toUpperCase()!==t.toLowerCase()}function N(t){return!!(t&&n(t)&&(t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>96&&t.charCodeAt(0)<123))}function P(t){return n(t)&&(t==='"'||t==="'"||t===c||t===u||t===l||t===a)}function M(t){return!n(t)||!i(t)?!1:t===t.toLowerCase()&&t!==t.toUpperCase()}function U(t){return!n(t)||!i(t)?!1:t===t.toUpperCase()&&t!==t.toLowerCase()}function F(t){return!n(t)||!t?!1:!t[0].trim()}var Q=t=>n(t)&&t.length&&t.endsWith("/")?t.slice(0,-1).trim():t;function d(t){if(t==null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null?!1:!(Symbol.iterator in t)&&!(Symbol.toStringTag in t)}function B(t="",e=0,r=0,o=""){return e<0&&(e+=t.length,e<0&&(e=0)),t.slice(0,e)+(o||"")+t.slice(e+r)}function n(t){return typeof t=="string"}function I(t){return Number.isFinite(t)}function E(t){return Number.isSafeInteger(t)&&t>=0}function q(t){return typeof t=="boolean"}function K(t){return t===null}function V(t,e){if(!n(t)||!n(e))return[];let r=[],o=-1;for(;(o=t.indexOf(e,o+1))>=0;)r.push(o);return r}function W(t=[],e=[]){return!t||!Array.isArray(t)||!t.length?[]:!e||!Array.isArray(e)||!e.length?t:t.filter(r=>!e.includes(r))}function Z(t){return t!=null}function z(t){return[...new Set(t)]}function G(t,e){return d(t)&&n(e)&&Object.prototype.hasOwnProperty.call(t,e)}var H=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],J=new Set(["a","abbr","acronym","audio","b","bdi","bdo","big","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","label","map","mark","meter","noscript","object","output","picture","progress","q","ruby","s","samp","script","select","slot","small","span","strong","sub","sup","svg","template","textarea","time","u","tt","var","video","wbr"]);export{T as backslash,L as backtick,S as doublePrime,w as ellipsis,Z as existy,V as findAllIdx,k as hairspace,G as hasOwnProp,J as inlineTags,q as isBool,m as isCurrencyChar,R as isCurrencySymbol,E as isInt,N as isLatinLetter,i as isLetter,M as isLowercaseLetter,K as isNull,I as isNum,D as isNumberChar,d as isPlainObject,P as isQuote,n as isStr,U as isUppercaseLetter,F as isWhitespaceChar,l as leftDoubleQuote,c as leftSingleQuote,O as multiplicationSign,W as pullAll,$ as punctuationChars,g as rawMDash,h as rawNDash,y as rawNbsp,A as rawReplacementMark,Q as removeTrailingSlash,a as rightDoubleQuote,u as rightSingleQuote,j as singlePrime,B as stringSplice,C as thinSpace,z as uniq,x as version,H as voidTags};
10
+ var s="1.5.0";var h=s,p="\u2018",c="\u2019",l="\u201C",a="\u201D",y="\u2013",w="\u2014",k="\xA0",S="\u2026",C="\u200A",O="\u2009",j="\u2032",A="\u2033",N="\\",E="\uFFFD",T="`",J="\xD7",R=[".",",",";","!","?"];function L(t){return r(t)&&t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57}function f(t){return r(t)&&"\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4".includes(t)}function $(t){let e=new Set(["$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]);return r(t)&&!!t.trim()&&(f(t)||e.has(t))}function i(t){return r(t)&&t.length===1&&t.toUpperCase()!==t.toLowerCase()}function D(t){return!!(t&&r(t)&&(t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>96&&t.charCodeAt(0)<123))}function F(t){return r(t)&&(t==='"'||t==="'"||t===p||t===c||t===l||t===a)}function P(t){return!r(t)||!i(t)?!1:t===t.toLowerCase()&&t!==t.toUpperCase()}function U(t){return!r(t)||!i(t)?!1:t===t.toUpperCase()&&t!==t.toLowerCase()}function M(t){return!r(t)||!t?!1:!t[0].trim()}var Q=t=>r(t)&&t.length&&t.endsWith("/")?t.slice(0,-1).trim():t;function d(t){if(t==null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null?!1:!(Symbol.iterator in t)&&!(Symbol.toStringTag in t)}function V(t="",e=0,n=0,o=""){return e<0&&(e+=t.length,e<0&&(e=0)),t.slice(0,e)+(o||"")+t.slice(e+n)}function r(t){return typeof t=="string"}function B(t){return Number.isFinite(t)}function I(t){return Number.isSafeInteger(t)&&t>=0}function K(t){return typeof t=="boolean"}function q(t){return t===null}function m(t){return t instanceof RegExp}function W(t,e){if(!r(t)||!r(e))return[];let n=[],o=-1;for(;(o=t.indexOf(e,o+1))>=0;)n.push(o);return n}function Z(t=[],e=[]){return!t||!Array.isArray(t)||!t.length?[]:!e||!Array.isArray(e)||!e.length?t:t.filter(n=>!e.includes(n))}function z(t){return t!=null}function G(t){return[...new Set(t)]}function x(t){if(!(typeof t!="string"||!t)){if(t.includes(`\r
11
+ `))return`\r
12
+ `;if(t.includes(`
13
+ `))return`
14
+ `;if(t.includes("\r"))return"\r"}}function H(t,e,n=`
15
+ `){if(![`\r
16
+ `,"\r",`
17
+ `].includes(n))throw new Error(`codsen-utils/resolveEolSetting(): the input argument defaultEolChar should be one of EOL values: "\\n", "\\r", or "\\r\\n", but it was given as ${JSON.stringify(n,null,0)}`);return e==="crlf"?`\r
18
+ `:e==="cr"?"\r":e==="lf"?`
19
+ `:x(t)||n}function X(t,e){return d(t)&&r(e)&&e in t}function Y(t,e){return t.localeCompare(e)}var _=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],v=new Set(["a","abbr","acronym","audio","b","bdi","bdo","big","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","label","map","mark","meter","noscript","object","output","picture","progress","q","ruby","s","samp","script","select","slot","small","span","strong","sub","sup","svg","template","textarea","time","u","tt","var","video","wbr"]);function tt(t,e){return!Array.isArray(t)||!t.length?!1:t.some(n=>m(n)&&e.match(n)||typeof n=="string"&&e===n)}export{N as backslash,T as backtick,Y as compareFn,x as detectEol,A as doublePrime,S as ellipsis,z as existy,W as findAllIdx,C as hairspace,X as hasOwnProp,tt as includes,v as inlineTags,K as isBool,f as isCurrencyChar,$ as isCurrencySymbol,I as isInt,D as isLatinLetter,i as isLetter,P as isLowercaseLetter,q as isNull,B as isNum,L as isNumberChar,d as isPlainObject,F as isQuote,m as isRegExp,r as isStr,U as isUppercaseLetter,M as isWhitespaceChar,l as leftDoubleQuote,p as leftSingleQuote,J as multiplicationSign,Z as pullAll,R as punctuationChars,w as rawMDash,y as rawNDash,k as rawNbsp,E as rawReplacementMark,Q as removeTrailingSlash,H as resolveEolSetting,a as rightDoubleQuote,c as rightSingleQuote,j as singlePrime,V as stringSplice,O as thinSpace,G as uniq,h as version,_ as voidTags};
@@ -1,10 +1,19 @@
1
1
  /**
2
2
  * @name codsen-utils
3
3
  * @fileoverview Various utility functions
4
- * @version 1.3.1
4
+ * @version 1.5.0
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/codsen-utils/}
8
8
  */
9
9
 
10
- "use strict";var codsenUtils=(()=>{var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var g=(t,e)=>{for(var r in e)i(t,r,{get:e[r],enumerable:!0})},y=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of x(e))!h.call(t,s)&&s!==r&&i(t,s,{get:()=>e[s],enumerable:!(o=f(e,s))||o.enumerable});return t};var w=t=>y(i({},"__esModule",{value:!0}),t);var nt={};g(nt,{backslash:()=>R,backtick:()=>P,doublePrime:()=>D,ellipsis:()=>A,existy:()=>Y,findAllIdx:()=>J,hairspace:()=>L,hasOwnProp:()=>v,inlineTags:()=>et,isBool:()=>G,isCurrencyChar:()=>d,isCurrencySymbol:()=>Q,isInt:()=>z,isLatinLetter:()=>B,isLetter:()=>p,isLowercaseLetter:()=>E,isNull:()=>H,isNum:()=>Z,isNumberChar:()=>F,isPlainObject:()=>b,isQuote:()=>I,isStr:()=>n,isUppercaseLetter:()=>q,isWhitespaceChar:()=>K,leftDoubleQuote:()=>a,leftSingleQuote:()=>u,multiplicationSign:()=>M,pullAll:()=>X,punctuationChars:()=>U,rawMDash:()=>S,rawNDash:()=>j,rawNbsp:()=>T,rawReplacementMark:()=>N,removeTrailingSlash:()=>V,rightDoubleQuote:()=>m,rightSingleQuote:()=>l,singlePrime:()=>$,stringSplice:()=>W,thinSpace:()=>O,uniq:()=>_,version:()=>C,voidTags:()=>tt});var c="1.3.1";var C=c,u="\u2018",l="\u2019",a="\u201C",m="\u201D",j="\u2013",S="\u2014",T="\xA0",A="\u2026",L="\u200A",O="\u2009",$="\u2032",D="\u2033",R="\\",N="\uFFFD",P="`",M="\xD7",U=[".",",",";","!","?"];function F(t){return n(t)&&t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57}function d(t){return n(t)&&"\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4".includes(t)}function Q(t){let e=new Set(["$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]);return n(t)&&!!t.trim()&&(d(t)||e.has(t))}function p(t){return n(t)&&t.length===1&&t.toUpperCase()!==t.toLowerCase()}function B(t){return!!(t&&n(t)&&(t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>96&&t.charCodeAt(0)<123))}function I(t){return n(t)&&(t==='"'||t==="'"||t===u||t===l||t===a||t===m)}function E(t){return!n(t)||!p(t)?!1:t===t.toLowerCase()&&t!==t.toUpperCase()}function q(t){return!n(t)||!p(t)?!1:t===t.toUpperCase()&&t!==t.toLowerCase()}function K(t){return!n(t)||!t?!1:!t[0].trim()}var V=t=>n(t)&&t.length&&t.endsWith("/")?t.slice(0,-1).trim():t;function b(t){if(t==null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null?!1:!(Symbol.iterator in t)&&!(Symbol.toStringTag in t)}function W(t="",e=0,r=0,o=""){return e<0&&(e+=t.length,e<0&&(e=0)),t.slice(0,e)+(o||"")+t.slice(e+r)}function n(t){return typeof t=="string"}function Z(t){return Number.isFinite(t)}function z(t){return Number.isSafeInteger(t)&&t>=0}function G(t){return typeof t=="boolean"}function H(t){return t===null}function J(t,e){if(!n(t)||!n(e))return[];let r=[],o=-1;for(;(o=t.indexOf(e,o+1))>=0;)r.push(o);return r}function X(t=[],e=[]){return!t||!Array.isArray(t)||!t.length?[]:!e||!Array.isArray(e)||!e.length?t:t.filter(r=>!e.includes(r))}function Y(t){return t!=null}function _(t){return[...new Set(t)]}function v(t,e){return b(t)&&n(e)&&Object.prototype.hasOwnProperty.call(t,e)}var tt=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],et=new Set(["a","abbr","acronym","audio","b","bdi","bdo","big","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","label","map","mark","meter","noscript","object","output","picture","progress","q","ruby","s","samp","script","select","slot","small","span","strong","sub","sup","svg","template","textarea","time","u","tt","var","video","wbr"]);return w(nt);})();
10
+ "use strict";var codsenUtils=(()=>{var i=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var w=(t,e)=>{for(var n in e)i(t,n,{get:e[n],enumerable:!0})},k=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of h(e))!y.call(t,s)&&s!==n&&i(t,s,{get:()=>e[s],enumerable:!(o=g(e,s))||o.enumerable});return t};var S=t=>k(i({},"__esModule",{value:!0}),t);var ut={};w(ut,{backslash:()=>$,backtick:()=>F,compareFn:()=>rt,detectEol:()=>b,doublePrime:()=>L,ellipsis:()=>E,existy:()=>v,findAllIdx:()=>Y,hairspace:()=>T,hasOwnProp:()=>nt,includes:()=>it,inlineTags:()=>st,isBool:()=>H,isCurrencyChar:()=>d,isCurrencySymbol:()=>Q,isInt:()=>G,isLatinLetter:()=>V,isLetter:()=>u,isLowercaseLetter:()=>I,isNull:()=>X,isNum:()=>z,isNumberChar:()=>M,isPlainObject:()=>m,isQuote:()=>B,isRegExp:()=>x,isStr:()=>r,isUppercaseLetter:()=>K,isWhitespaceChar:()=>q,leftDoubleQuote:()=>a,leftSingleQuote:()=>c,multiplicationSign:()=>P,pullAll:()=>_,punctuationChars:()=>U,rawMDash:()=>A,rawNDash:()=>j,rawNbsp:()=>N,rawReplacementMark:()=>D,removeTrailingSlash:()=>W,resolveEolSetting:()=>et,rightDoubleQuote:()=>f,rightSingleQuote:()=>l,singlePrime:()=>R,stringSplice:()=>Z,thinSpace:()=>J,uniq:()=>tt,version:()=>O,voidTags:()=>ot});var p="1.5.0";var O=p,c="\u2018",l="\u2019",a="\u201C",f="\u201D",j="\u2013",A="\u2014",N="\xA0",E="\u2026",T="\u200A",J="\u2009",R="\u2032",L="\u2033",$="\\",D="\uFFFD",F="`",P="\xD7",U=[".",",",";","!","?"];function M(t){return r(t)&&t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57}function d(t){return r(t)&&"\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4".includes(t)}function Q(t){let e=new Set(["$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]);return r(t)&&!!t.trim()&&(d(t)||e.has(t))}function u(t){return r(t)&&t.length===1&&t.toUpperCase()!==t.toLowerCase()}function V(t){return!!(t&&r(t)&&(t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>96&&t.charCodeAt(0)<123))}function B(t){return r(t)&&(t==='"'||t==="'"||t===c||t===l||t===a||t===f)}function I(t){return!r(t)||!u(t)?!1:t===t.toLowerCase()&&t!==t.toUpperCase()}function K(t){return!r(t)||!u(t)?!1:t===t.toUpperCase()&&t!==t.toLowerCase()}function q(t){return!r(t)||!t?!1:!t[0].trim()}var W=t=>r(t)&&t.length&&t.endsWith("/")?t.slice(0,-1).trim():t;function m(t){if(t==null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null?!1:!(Symbol.iterator in t)&&!(Symbol.toStringTag in t)}function Z(t="",e=0,n=0,o=""){return e<0&&(e+=t.length,e<0&&(e=0)),t.slice(0,e)+(o||"")+t.slice(e+n)}function r(t){return typeof t=="string"}function z(t){return Number.isFinite(t)}function G(t){return Number.isSafeInteger(t)&&t>=0}function H(t){return typeof t=="boolean"}function X(t){return t===null}function x(t){return t instanceof RegExp}function Y(t,e){if(!r(t)||!r(e))return[];let n=[],o=-1;for(;(o=t.indexOf(e,o+1))>=0;)n.push(o);return n}function _(t=[],e=[]){return!t||!Array.isArray(t)||!t.length?[]:!e||!Array.isArray(e)||!e.length?t:t.filter(n=>!e.includes(n))}function v(t){return t!=null}function tt(t){return[...new Set(t)]}function b(t){if(!(typeof t!="string"||!t)){if(t.includes(`\r
11
+ `))return`\r
12
+ `;if(t.includes(`
13
+ `))return`
14
+ `;if(t.includes("\r"))return"\r"}}function et(t,e,n=`
15
+ `){if(![`\r
16
+ `,"\r",`
17
+ `].includes(n))throw new Error(`codsen-utils/resolveEolSetting(): the input argument defaultEolChar should be one of EOL values: "\\n", "\\r", or "\\r\\n", but it was given as ${JSON.stringify(n,null,0)}`);return e==="crlf"?`\r
18
+ `:e==="cr"?"\r":e==="lf"?`
19
+ `:b(t)||n}function nt(t,e){return m(t)&&r(e)&&e in t}function rt(t,e){return t.localeCompare(e)}var ot=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],st=new Set(["a","abbr","acronym","audio","b","bdi","bdo","big","br","button","canvas","cite","code","data","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","label","map","mark","meter","noscript","object","output","picture","progress","q","ruby","s","samp","script","select","slot","small","span","strong","sub","sup","svg","template","textarea","time","u","tt","var","video","wbr"]);function it(t,e){return!Array.isArray(t)||!t.length?!1:t.some(n=>x(n)&&e.match(n)||typeof n=="string"&&e===n)}return S(ut);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codsen-utils",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "description": "Various utility functions",
5
5
  "keywords": [
6
6
  "codsen",
@@ -49,6 +49,7 @@
49
49
  "node": ">=14.18.0"
50
50
  },
51
51
  "c8": {
52
+ "branches": 100,
52
53
  "check-coverage": true,
53
54
  "exclude": [
54
55
  "**/test/**/*.*"
package/types/index.d.ts CHANGED
@@ -16,9 +16,17 @@ declare const rawReplacementMark = "\uFFFD";
16
16
  declare const backtick = "`";
17
17
  declare const multiplicationSign = "\u00D7";
18
18
  declare const punctuationChars: string[];
19
- interface Obj {
20
- [key: string]: any;
19
+ type JSONValue = string | number | boolean | null | JSONObject | JSONArray;
20
+ type JsonObject = {
21
+ [Key in string]?: JSONValue;
22
+ };
23
+ type JSONArray = JSONValue[];
24
+ interface JSONObject {
25
+ [key: string]: JSONValue;
21
26
  }
27
+ type Obj = JSONObject;
28
+ type EolChar = "\n" | "\r" | "\r\n";
29
+ type EolSetting = "lf" | "crlf" | "cr";
22
30
  declare function isNumberChar(value: unknown): boolean;
23
31
  declare function isCurrencyChar(value: unknown): boolean;
24
32
  declare function isCurrencySymbol(value: unknown): boolean;
@@ -35,7 +43,7 @@ declare const removeTrailingSlash: <T>(value: T) => string | T;
35
43
  * @param value unknown
36
44
  * @returns boolean
37
45
  */
38
- declare function isPlainObject(value: unknown): boolean;
46
+ declare function isPlainObject(value: unknown): value is JSONObject;
39
47
  /**
40
48
  * @param str input string
41
49
  * @param index starting index
@@ -55,6 +63,7 @@ declare function isNum(something: unknown): something is number;
55
63
  declare function isInt(something: unknown): something is number;
56
64
  declare function isBool(something: unknown): something is boolean;
57
65
  declare function isNull(something: unknown): something is null;
66
+ declare function isRegExp(something: any): something is RegExp;
58
67
  /**
59
68
  * Gives array of indexes of all found substring occurrences
60
69
  * @param string source string
@@ -79,20 +88,51 @@ declare function existy(x: unknown): boolean;
79
88
  * @returns de-duped array
80
89
  */
81
90
  declare function uniq<T>(input: T[]): T[];
91
+ declare function detectEol(str: string | unknown): EolChar | undefined;
92
+ declare function resolveEolSetting(
93
+ str: string | unknown,
94
+ eolSetting: EolSetting | unknown,
95
+ defaultEolChar?: EolChar
96
+ ): EolChar;
82
97
  declare function hasOwnProp(obj: unknown, prop: string): boolean;
98
+ /**
99
+ * Related to @typescript-eslint/require-array-sort-compare lint error
100
+ */
101
+ declare function compareFn(a: string, b: string): number;
83
102
  declare const voidTags: string[];
84
103
  declare const inlineTags: Set<string>;
104
+ /**
105
+ * Like Array.prototype.includes() but it takes a mix of strings and/or
106
+ * regex'es, and matches that against a string. It's also a friendly API,
107
+ * it will not throw if the inputs are wrong.
108
+ * @param arr - array of zero or more strings or regex'es
109
+ * @param whatToMatch - string to match
110
+ * @returns boolean
111
+ */
112
+ declare function includes(
113
+ arr: (string | RegExp)[],
114
+ whatToMatch: string
115
+ ): boolean;
85
116
 
86
117
  export {
118
+ EolChar,
119
+ EolSetting,
120
+ JSONArray,
121
+ JSONObject,
122
+ JSONValue,
123
+ JsonObject,
87
124
  Obj,
88
125
  backslash,
89
126
  backtick,
127
+ compareFn,
128
+ detectEol,
90
129
  doublePrime,
91
130
  ellipsis,
92
131
  existy,
93
132
  findAllIdx,
94
133
  hairspace,
95
134
  hasOwnProp,
135
+ includes,
96
136
  inlineTags,
97
137
  isBool,
98
138
  isCurrencyChar,
@@ -106,6 +146,7 @@ export {
106
146
  isNumberChar,
107
147
  isPlainObject,
108
148
  isQuote,
149
+ isRegExp,
109
150
  isStr,
110
151
  isUppercaseLetter,
111
152
  isWhitespaceChar,
@@ -119,6 +160,7 @@ export {
119
160
  rawNbsp,
120
161
  rawReplacementMark,
121
162
  removeTrailingSlash,
163
+ resolveEolSetting,
122
164
  rightDoubleQuote,
123
165
  rightSingleQuote,
124
166
  singlePrime,