codsen-utils 1.4.0 → 1.6.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,14 +3,32 @@
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.4.0](https://github.com/codsen/codsen/compare/codsen-utils@1.3.1...codsen-utils@1.4.0) (2023-04-16)
6
+ ## 1.6.0 (2023-05-21)
7
+
8
+ ### Features
9
+
10
+ - add `intersection()` and `omit()` ([d71f024](https://github.com/codsen/codsen/commit/d71f024dd3223dfbf2182dbb7c28ac592b13bba2))
11
+
12
+ ## 1.5.0 (2023-05-13)
13
+
14
+ ### Bug Fixes
15
+
16
+ - type improvements ([6847c21](https://github.com/codsen/codsen/commit/6847c21ce33b36e56b767ef63504d9233810d2e9))
17
+ - type tweaks ([8173408](https://github.com/codsen/codsen/commit/8173408b57f963055cca991a0cb697c9d2d664e4))
18
+
19
+ ### Features
20
+
21
+ - add `compareFn()` to tackle `@typescript-eslint/require-array-sort-compare` lint rule ([a25524a](https://github.com/codsen/codsen/commit/a25524a027067208b8e94b30b6745790ec278fbe))
22
+ - add `includes()` ([c6cf14e](https://github.com/codsen/codsen/commit/c6cf14e8a7f3fb2a063fcec3381700798341ad42))
23
+
24
+ ## 1.4.0 (2023-04-16)
7
25
 
8
26
  ### Features
9
27
 
10
28
  - add `detectEol()` ([04d2f3d](https://github.com/codsen/codsen/commit/04d2f3d36963e1b1729887098126cba5719d97c0))
11
29
  - add `resolveEolSetting()` and type `EolSetting` ([ceae282](https://github.com/codsen/codsen/commit/ceae282e1f9240638e0aefc57eab48dde9de6ba1))
12
30
 
13
- # [1.3.0](https://github.com/codsen/codsen/compare/codsen-utils@1.2.0...codsen-utils@1.3.0) (2023-03-12)
31
+ ## 1.3.0 (2023-03-12)
14
32
 
15
33
  ### Features
16
34
 
@@ -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.6.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.6.0";import p from"rfdc";var l=p(),k=s,a="\u2018",f="\u2019",d="\u201C",m="\u201D",S="\u2013",O="\u2014",C="\xA0",N="\u2026",A="\u200A",j="\u2009",E="\u2032",T="\u2033",J="\\",R="\uFFFD",$="`",L="\xD7",D=[".",",",";","!","?"];function U(t){return r(t)&&t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57}function x(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 F(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()&&(x(t)||e.has(t))}function i(t){return r(t)&&t.length===1&&t.toUpperCase()!==t.toLowerCase()}function I(t){return!!(t&&r(t)&&(t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>96&&t.charCodeAt(0)<123))}function P(t){return r(t)&&(t==='"'||t==="'"||t===a||t===f||t===d||t===m)}function M(t){return!r(t)||!i(t)?!1:t===t.toLowerCase()&&t!==t.toUpperCase()}function Q(t){return!r(t)||!i(t)?!1:t===t.toUpperCase()&&t!==t.toLowerCase()}function V(t){return!r(t)||!t?!1:!t[0].trim()}var B=t=>r(t)&&t.length&&t.endsWith("/")?t.slice(0,-1).trim():t;function u(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 K(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 W(t){return Number.isFinite(t)}function q(t){return Number.isSafeInteger(t)&&t>=0}function H(t){return typeof t=="boolean"}function Z(t){return t===null}function b(t){return t instanceof RegExp}function _(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 G(t){return t!=null}function X(t){return[...new Set(t)]}function g(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 Y(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
+ `:g(t)||n}function v(t,e){return u(t)&&r(e)&&e in t}function tt(t,e){return t.localeCompare(e)}var et=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],nt=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 rt(t,e){return!Array.isArray(t)||!t.length?!1:t.some(n=>b(n)&&e.match(n)||typeof n=="string"&&e===n)}function ot(t=[],e=[]){return!t||!e?[]:Array.from(new Set(Array.from(t).filter(n=>new Set(e).has(n))))}function st(t,e=[]){if(!t)return t;if(!u(t))throw new Error(`codsen-utils/omit(): [THROW_ID_01] Input must be a plain object! It was given as ${JSON.stringify(t,null,4)} (typeof is "${typeof t}")`);let n=l(t);return e.forEach(o=>{delete n[o]}),n}export{J as backslash,$ as backtick,tt as compareFn,g as detectEol,T as doublePrime,N as ellipsis,G as existy,_ as findAllIdx,A as hairspace,v as hasOwnProp,rt as includes,nt as inlineTags,ot as intersection,H as isBool,x as isCurrencyChar,F as isCurrencySymbol,q as isInt,I as isLatinLetter,i as isLetter,M as isLowercaseLetter,Z as isNull,W as isNum,U as isNumberChar,u as isPlainObject,P as isQuote,b as isRegExp,r as isStr,Q as isUppercaseLetter,V as isWhitespaceChar,d as leftDoubleQuote,a as leftSingleQuote,L as multiplicationSign,st as omit,z as pullAll,D as punctuationChars,O as rawMDash,S as rawNDash,C as rawNbsp,R as rawReplacementMark,B as removeTrailingSlash,Y as resolveEolSetting,m as rightDoubleQuote,f as rightSingleQuote,E as singlePrime,K as stringSplice,j as thinSpace,X as uniq,k as version,et 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.6.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 J=Object.create;var w=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var V=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),P=(e,n)=>{for(var o in n)w(e,o,{get:n[o],enumerable:!0})},g=(e,n,o,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of R(n))!L.call(e,i)&&i!==o&&w(e,i,{get:()=>n[i],enumerable:!(f=B(n,i))||f.enumerable});return e};var U=(e,n,o)=>(o=e!=null?J($(e)):{},g(n||!e||!e.__esModule?w(o,"default",{value:e,enumerable:!0}):o,e)),F=e=>g(w({},"__esModule",{value:!0}),e);var S=V((Be,A)=>{"use strict";A.exports=k;function m(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function k(e){if(e=e||{},e.circles)return Q(e);return e.proto?f:o;function n(i,p){for(var t=Object.keys(i),r=new Array(t.length),a=0;a<t.length;a++){var s=t[a],l=i[s];typeof l!="object"||l===null?r[s]=l:l instanceof Date?r[s]=new Date(l):ArrayBuffer.isView(l)?r[s]=m(l):r[s]=p(l)}return r}function o(i){if(typeof i!="object"||i===null)return i;if(i instanceof Date)return new Date(i);if(Array.isArray(i))return n(i,o);if(i instanceof Map)return new Map(n(Array.from(i),o));if(i instanceof Set)return new Set(n(Array.from(i),o));var p={};for(var t in i)if(Object.hasOwnProperty.call(i,t)!==!1){var r=i[t];typeof r!="object"||r===null?p[t]=r:r instanceof Date?p[t]=new Date(r):r instanceof Map?p[t]=new Map(n(Array.from(r),o)):r instanceof Set?p[t]=new Set(n(Array.from(r),o)):ArrayBuffer.isView(r)?p[t]=m(r):p[t]=o(r)}return p}function f(i){if(typeof i!="object"||i===null)return i;if(i instanceof Date)return new Date(i);if(Array.isArray(i))return n(i,f);if(i instanceof Map)return new Map(n(Array.from(i),f));if(i instanceof Set)return new Set(n(Array.from(i),f));var p={};for(var t in i){var r=i[t];typeof r!="object"||r===null?p[t]=r:r instanceof Date?p[t]=new Date(r):r instanceof Map?p[t]=new Map(n(Array.from(r),f)):r instanceof Set?p[t]=new Set(n(Array.from(r),f)):ArrayBuffer.isView(r)?p[t]=m(r):p[t]=f(r)}return p}}function Q(e){var n=[],o=[];return e.proto?p:i;function f(t,r){for(var a=Object.keys(t),s=new Array(a.length),l=0;l<a.length;l++){var y=a[l],c=t[y];if(typeof c!="object"||c===null)s[y]=c;else if(c instanceof Date)s[y]=new Date(c);else if(ArrayBuffer.isView(c))s[y]=m(c);else{var x=n.indexOf(c);x!==-1?s[y]=o[x]:s[y]=r(c)}}return s}function i(t){if(typeof t!="object"||t===null)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return f(t,i);if(t instanceof Map)return new Map(f(Array.from(t),i));if(t instanceof Set)return new Set(f(Array.from(t),i));var r={};n.push(t),o.push(r);for(var a in t)if(Object.hasOwnProperty.call(t,a)!==!1){var s=t[a];if(typeof s!="object"||s===null)r[a]=s;else if(s instanceof Date)r[a]=new Date(s);else if(s instanceof Map)r[a]=new Map(f(Array.from(s),i));else if(s instanceof Set)r[a]=new Set(f(Array.from(s),i));else if(ArrayBuffer.isView(s))r[a]=m(s);else{var l=n.indexOf(s);l!==-1?r[a]=o[l]:r[a]=i(s)}}return n.pop(),o.pop(),r}function p(t){if(typeof t!="object"||t===null)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return f(t,p);if(t instanceof Map)return new Map(f(Array.from(t),p));if(t instanceof Set)return new Set(f(Array.from(t),p));var r={};n.push(t),o.push(r);for(var a in t){var s=t[a];if(typeof s!="object"||s===null)r[a]=s;else if(s instanceof Date)r[a]=new Date(s);else if(s instanceof Map)r[a]=new Map(f(Array.from(s),p));else if(s instanceof Set)r[a]=new Set(f(Array.from(s),p));else if(ArrayBuffer.isView(s))r[a]=m(s);else{var l=n.indexOf(s);l!==-1?r[a]=o[l]:r[a]=p(s)}}return n.pop(),o.pop(),r}}});var Ee={};P(Ee,{backslash:()=>Y,backtick:()=>ne,compareFn:()=>Oe,detectEol:()=>T,doublePrime:()=>X,ellipsis:()=>Z,existy:()=>ge,findAllIdx:()=>de,hairspace:()=>_,hasOwnProp:()=>Se,includes:()=>Ce,inlineTags:()=>De,intersection:()=>Ne,isBool:()=>we,isCurrencyChar:()=>M,isCurrencySymbol:()=>ie,isInt:()=>me,isLatinLetter:()=>se,isLetter:()=>b,isLowercaseLetter:()=>ae,isNull:()=>be,isNum:()=>ye,isNumberChar:()=>oe,isPlainObject:()=>d,isQuote:()=>fe,isRegExp:()=>E,isStr:()=>u,isUppercaseLetter:()=>pe,isWhitespaceChar:()=>le,leftDoubleQuote:()=>C,leftSingleQuote:()=>j,multiplicationSign:()=>te,omit:()=>Me,pullAll:()=>xe,punctuationChars:()=>re,rawMDash:()=>q,rawNDash:()=>W,rawNbsp:()=>H,rawReplacementMark:()=>ee,removeTrailingSlash:()=>ue,resolveEolSetting:()=>Ae,rightDoubleQuote:()=>N,rightSingleQuote:()=>D,singlePrime:()=>G,stringSplice:()=>ce,thinSpace:()=>z,uniq:()=>he,version:()=>K,voidTags:()=>je});var h="1.6.0";var O=U(S(),1),v=(0,O.default)(),K=h,j="\u2018",D="\u2019",C="\u201C",N="\u201D",W="\u2013",q="\u2014",H="\xA0",Z="\u2026",_="\u200A",z="\u2009",G="\u2032",X="\u2033",Y="\\",ee="\uFFFD",ne="`",te="\xD7",re=[".",",",";","!","?"];function oe(e){return u(e)&&e.charCodeAt(0)>=48&&e.charCodeAt(0)<=57}function M(e){return u(e)&&"\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4".includes(e)}function ie(e){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 u(e)&&!!e.trim()&&(M(e)||n.has(e))}function b(e){return u(e)&&e.length===1&&e.toUpperCase()!==e.toLowerCase()}function se(e){return!!(e&&u(e)&&(e.charCodeAt(0)>64&&e.charCodeAt(0)<91||e.charCodeAt(0)>96&&e.charCodeAt(0)<123))}function fe(e){return u(e)&&(e==='"'||e==="'"||e===j||e===D||e===C||e===N)}function ae(e){return!u(e)||!b(e)?!1:e===e.toLowerCase()&&e!==e.toUpperCase()}function pe(e){return!u(e)||!b(e)?!1:e===e.toUpperCase()&&e!==e.toLowerCase()}function le(e){return!u(e)||!e?!1:!e[0].trim()}var ue=e=>u(e)&&e.length&&e.endsWith("/")?e.slice(0,-1).trim():e;function d(e){if(e==null||typeof e!="object")return!1;let n=Object.getPrototypeOf(e);return n!==null&&n!==Object.prototype&&Object.getPrototypeOf(n)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function ce(e="",n=0,o=0,f=""){return n<0&&(n+=e.length,n<0&&(n=0)),e.slice(0,n)+(f||"")+e.slice(n+o)}function u(e){return typeof e=="string"}function ye(e){return Number.isFinite(e)}function me(e){return Number.isSafeInteger(e)&&e>=0}function we(e){return typeof e=="boolean"}function be(e){return e===null}function E(e){return e instanceof RegExp}function de(e,n){if(!u(e)||!u(n))return[];let o=[],f=-1;for(;(f=e.indexOf(n,f+1))>=0;)o.push(f);return o}function xe(e=[],n=[]){return!e||!Array.isArray(e)||!e.length?[]:!n||!Array.isArray(n)||!n.length?e:e.filter(o=>!n.includes(o))}function ge(e){return e!=null}function he(e){return[...new Set(e)]}function T(e){if(!(typeof e!="string"||!e)){if(e.includes(`\r
11
11
  `))return`\r
12
- `;if(t.includes(`
12
+ `;if(e.includes(`
13
13
  `))return`
14
- `;if(t.includes("\r"))return"\r"}}function tt(t,n,e=`
14
+ `;if(e.includes("\r"))return"\r"}}function Ae(e,n,o=`
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
17
+ `].includes(o))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(o,null,0)}`);return n==="crlf"?`\r
18
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);})();
19
+ `:T(e)||o}function Se(e,n){return d(e)&&u(n)&&n in e}function Oe(e,n){return e.localeCompare(n)}var je=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],De=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 Ce(e,n){return!Array.isArray(e)||!e.length?!1:e.some(o=>E(o)&&n.match(o)||typeof o=="string"&&n===o)}function Ne(e=[],n=[]){return!e||!n?[]:Array.from(new Set(Array.from(e).filter(o=>new Set(n).has(o))))}function Me(e,n=[]){if(!e)return e;if(!d(e))throw new Error(`codsen-utils/omit(): [THROW_ID_01] Input must be a plain object! It was given as ${JSON.stringify(e,null,4)} (typeof is "${typeof e}")`);let o=v(e);return n.forEach(f=>{delete o[f]}),o}return F(Ee);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codsen-utils",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "Various utility functions",
5
5
  "keywords": [
6
6
  "codsen",
@@ -63,5 +63,8 @@
63
63
  ""
64
64
  ]
65
65
  }
66
+ },
67
+ "dependencies": {
68
+ "rfdc": "^1.3.0"
66
69
  }
67
70
  }
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,40 @@ 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;
116
+ /** Alternative to lodash.intersection */
117
+ declare function intersection<T, U>(a?: T[], b?: U[]): T[];
118
+ /** Alternative to lodash.omit */
119
+ declare function omit(obj: JSONObject, keysToRemove?: string[]): JSONObject;
93
120
 
94
121
  export {
95
122
  EolChar,
96
123
  EolSetting,
124
+ JSONArray,
125
+ JSONObject,
126
+ JSONValue,
127
+ JsonObject,
97
128
  Obj,
98
129
  backslash,
99
130
  backtick,
131
+ compareFn,
100
132
  detectEol,
101
133
  doublePrime,
102
134
  ellipsis,
@@ -104,7 +136,9 @@ export {
104
136
  findAllIdx,
105
137
  hairspace,
106
138
  hasOwnProp,
139
+ includes,
107
140
  inlineTags,
141
+ intersection,
108
142
  isBool,
109
143
  isCurrencyChar,
110
144
  isCurrencySymbol,
@@ -117,12 +151,14 @@ export {
117
151
  isNumberChar,
118
152
  isPlainObject,
119
153
  isQuote,
154
+ isRegExp,
120
155
  isStr,
121
156
  isUppercaseLetter,
122
157
  isWhitespaceChar,
123
158
  leftDoubleQuote,
124
159
  leftSingleQuote,
125
160
  multiplicationSign,
161
+ omit,
126
162
  pullAll,
127
163
  punctuationChars,
128
164
  rawMDash,