codsen-utils 1.4.0 → 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,18 @@
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
+
6
18
  # [1.4.0](https://github.com/codsen/codsen/compare/codsen-utils@1.3.1...codsen-utils@1.4.0) (2023-04-16)
7
19
 
8
20
  ### Features
@@ -1,19 +1,19 @@
1
1
  /**
2
2
  * @name codsen-utils
3
3
  * @fileoverview Various utility functions
4
- * @version 1.4.0
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.4.0";var h=s,c="\u2018",p="\u2019",l="\u201C",a="\u201D",g="\u2013",w="\u2014",y="\xA0",k="\u2026",C="\u200A",S="\u2009",j="\u2032",T="\u2033",A="\\",E="\uFFFD",O="`",L="\xD7",$=[".",",",";","!","?"];function D(t){return e(t)&&t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57}function f(t){return e(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 N(t){let n=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 e(t)&&!!t.trim()&&(f(t)||n.has(t))}function i(t){return e(t)&&t.length===1&&t.toUpperCase()!==t.toLowerCase()}function R(t){return!!(t&&e(t)&&(t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>96&&t.charCodeAt(0)<123))}function P(t){return e(t)&&(t==='"'||t==="'"||t===c||t===p||t===l||t===a)}function M(t){return!e(t)||!i(t)?!1:t===t.toLowerCase()&&t!==t.toUpperCase()}function U(t){return!e(t)||!i(t)?!1:t===t.toUpperCase()&&t!==t.toLowerCase()}function F(t){return!e(t)||!t?!1:!t[0].trim()}var Q=t=>e(t)&&t.length&&t.endsWith("/")?t.slice(0,-1).trim():t;function d(t){if(t==null||typeof t!="object")return!1;let n=Object.getPrototypeOf(t);return n!==null&&n!==Object.prototype&&Object.getPrototypeOf(n)!==null?!1:!(Symbol.iterator in t)&&!(Symbol.toStringTag in t)}function B(t="",n=0,r=0,o=""){return n<0&&(n+=t.length,n<0&&(n=0)),t.slice(0,n)+(o||"")+t.slice(n+r)}function e(t){return typeof t=="string"}function I(t){return Number.isFinite(t)}function q(t){return Number.isSafeInteger(t)&&t>=0}function J(t){return typeof t=="boolean"}function K(t){return t===null}function V(t,n){if(!e(t)||!e(n))return[];let r=[],o=-1;for(;(o=t.indexOf(n,o+1))>=0;)r.push(o);return r}function W(t=[],n=[]){return!t||!Array.isArray(t)||!t.length?[]:!n||!Array.isArray(n)||!n.length?t:t.filter(r=>!n.includes(r))}function Z(t){return t!=null}function z(t){return[...new Set(t)]}function m(t){if(!(typeof t!="string"||!t)){if(t.includes(`\r
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
11
  `))return`\r
12
12
  `;if(t.includes(`
13
13
  `))return`
14
- `;if(t.includes("\r"))return"\r"}}function G(t,n,r=`
14
+ `;if(t.includes("\r"))return"\r"}}function H(t,e,n=`
15
15
  `){if(![`\r
16
16
  `,"\r",`
17
- `].includes(r))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(r,null,0)}`);return n==="crlf"?`\r
18
- `:n==="cr"?"\r":n==="lf"?`
19
- `:m(t)||r}function H(t,n){return d(t)&&e(n)&&Object.prototype.hasOwnProperty.call(t,n)}var X=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],Y=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{A as backslash,O as backtick,m as detectEol,T as doublePrime,k as ellipsis,Z as existy,V as findAllIdx,C as hairspace,H as hasOwnProp,Y as inlineTags,J as isBool,f as isCurrencyChar,N as isCurrencySymbol,q as isInt,R as isLatinLetter,i as isLetter,M as isLowercaseLetter,K as isNull,I as isNum,D as isNumberChar,d as isPlainObject,P as isQuote,e as isStr,U as isUppercaseLetter,F as isWhitespaceChar,l as leftDoubleQuote,c as leftSingleQuote,L as multiplicationSign,W as pullAll,$ as punctuationChars,w as rawMDash,g as rawNDash,y as rawNbsp,E as rawReplacementMark,Q as removeTrailingSlash,G as resolveEolSetting,a as rightDoubleQuote,p as rightSingleQuote,j as singlePrime,B as stringSplice,S as thinSpace,z as uniq,h as version,X as voidTags};
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,19 +1,19 @@
1
1
  /**
2
2
  * @name codsen-utils
3
3
  * @fileoverview Various utility functions
4
- * @version 1.4.0
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 x=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var w=(t,n)=>{for(var e in n)i(t,e,{get:n[e],enumerable:!0})},y=(t,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of h(n))!g.call(t,s)&&s!==e&&i(t,s,{get:()=>n[s],enumerable:!(o=x(n,s))||o.enumerable});return t};var k=t=>y(i({},"__esModule",{value:!0}),t);var ot={};w(ot,{backslash:()=>N,backtick:()=>P,detectEol:()=>b,doublePrime:()=>D,ellipsis:()=>E,existy:()=>_,findAllIdx:()=>X,hairspace:()=>O,hasOwnProp:()=>nt,inlineTags:()=>rt,isBool:()=>G,isCurrencyChar:()=>d,isCurrencySymbol:()=>Q,isInt:()=>z,isLatinLetter:()=>B,isLetter:()=>u,isLowercaseLetter:()=>q,isNull:()=>H,isNum:()=>Z,isNumberChar:()=>F,isPlainObject:()=>m,isQuote:()=>I,isStr:()=>r,isUppercaseLetter:()=>J,isWhitespaceChar:()=>K,leftDoubleQuote:()=>a,leftSingleQuote:()=>p,multiplicationSign:()=>M,pullAll:()=>Y,punctuationChars:()=>U,rawMDash:()=>T,rawNDash:()=>j,rawNbsp:()=>A,rawReplacementMark:()=>R,removeTrailingSlash:()=>V,resolveEolSetting:()=>tt,rightDoubleQuote:()=>f,rightSingleQuote:()=>l,singlePrime:()=>$,stringSplice:()=>W,thinSpace:()=>L,uniq:()=>v,version:()=>S,voidTags:()=>et});var c="1.4.0";var S=c,p="\u2018",l="\u2019",a="\u201C",f="\u201D",j="\u2013",T="\u2014",A="\xA0",E="\u2026",O="\u200A",L="\u2009",$="\u2032",D="\u2033",N="\\",R="\uFFFD",P="`",M="\xD7",U=[".",",",";","!","?"];function F(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 n=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)||n.has(t))}function u(t){return r(t)&&t.length===1&&t.toUpperCase()!==t.toLowerCase()}function B(t){return!!(t&&r(t)&&(t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>96&&t.charCodeAt(0)<123))}function I(t){return r(t)&&(t==='"'||t==="'"||t===p||t===l||t===a||t===f)}function q(t){return!r(t)||!u(t)?!1:t===t.toLowerCase()&&t!==t.toUpperCase()}function J(t){return!r(t)||!u(t)?!1:t===t.toUpperCase()&&t!==t.toLowerCase()}function K(t){return!r(t)||!t?!1:!t[0].trim()}var V=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 n=Object.getPrototypeOf(t);return n!==null&&n!==Object.prototype&&Object.getPrototypeOf(n)!==null?!1:!(Symbol.iterator in t)&&!(Symbol.toStringTag in t)}function W(t="",n=0,e=0,o=""){return n<0&&(n+=t.length,n<0&&(n=0)),t.slice(0,n)+(o||"")+t.slice(n+e)}function r(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 X(t,n){if(!r(t)||!r(n))return[];let e=[],o=-1;for(;(o=t.indexOf(n,o+1))>=0;)e.push(o);return e}function Y(t=[],n=[]){return!t||!Array.isArray(t)||!t.length?[]:!n||!Array.isArray(n)||!n.length?t:t.filter(e=>!n.includes(e))}function _(t){return t!=null}function v(t){return[...new Set(t)]}function b(t){if(!(typeof t!="string"||!t)){if(t.includes(`\r
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
11
  `))return`\r
12
12
  `;if(t.includes(`
13
13
  `))return`
14
- `;if(t.includes("\r"))return"\r"}}function tt(t,n,e=`
14
+ `;if(t.includes("\r"))return"\r"}}function et(t,e,n=`
15
15
  `){if(![`\r
16
16
  `,"\r",`
17
- `].includes(e))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(e,null,0)}`);return n==="crlf"?`\r
18
- `:n==="cr"?"\r":n==="lf"?`
19
- `:b(t)||e}function nt(t,n){return m(t)&&r(n)&&Object.prototype.hasOwnProperty.call(t,n)}var et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],rt=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 k(ot);})();
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.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Various utility functions",
5
5
  "keywords": [
6
6
  "codsen",
package/types/index.d.ts CHANGED
@@ -16,9 +16,15 @@ 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;
22
28
  type EolChar = "\n" | "\r" | "\r\n";
23
29
  type EolSetting = "lf" | "crlf" | "cr";
24
30
  declare function isNumberChar(value: unknown): boolean;
@@ -37,7 +43,7 @@ declare const removeTrailingSlash: <T>(value: T) => string | T;
37
43
  * @param value unknown
38
44
  * @returns boolean
39
45
  */
40
- declare function isPlainObject(value: unknown): boolean;
46
+ declare function isPlainObject(value: unknown): value is JSONObject;
41
47
  /**
42
48
  * @param str input string
43
49
  * @param index starting index
@@ -57,6 +63,7 @@ declare function isNum(something: unknown): something is number;
57
63
  declare function isInt(something: unknown): something is number;
58
64
  declare function isBool(something: unknown): something is boolean;
59
65
  declare function isNull(something: unknown): something is null;
66
+ declare function isRegExp(something: any): something is RegExp;
60
67
  /**
61
68
  * Gives array of indexes of all found substring occurrences
62
69
  * @param string source string
@@ -88,15 +95,36 @@ declare function resolveEolSetting(
88
95
  defaultEolChar?: EolChar
89
96
  ): EolChar;
90
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;
91
102
  declare const voidTags: string[];
92
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;
93
116
 
94
117
  export {
95
118
  EolChar,
96
119
  EolSetting,
120
+ JSONArray,
121
+ JSONObject,
122
+ JSONValue,
123
+ JsonObject,
97
124
  Obj,
98
125
  backslash,
99
126
  backtick,
127
+ compareFn,
100
128
  detectEol,
101
129
  doublePrime,
102
130
  ellipsis,
@@ -104,6 +132,7 @@ export {
104
132
  findAllIdx,
105
133
  hairspace,
106
134
  hasOwnProp,
135
+ includes,
107
136
  inlineTags,
108
137
  isBool,
109
138
  isCurrencyChar,
@@ -117,6 +146,7 @@ export {
117
146
  isNumberChar,
118
147
  isPlainObject,
119
148
  isQuote,
149
+ isRegExp,
120
150
  isStr,
121
151
  isUppercaseLetter,
122
152
  isWhitespaceChar,