codsen-utils 1.1.1 → 1.3.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 +15 -2
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/codsen-utils.esm.js +2 -2
- package/dist/codsen-utils.umd.js +2 -2
- package/package.json +1 -1
- package/types/index.d.ts +37 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,13 +3,26 @@
|
|
|
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
|
-
|
|
6
|
+
# [1.3.0](https://github.com/codsen/codsen/compare/codsen-utils@1.2.0...codsen-utils@1.3.0) (2023-03-12)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add new functions ([aee27c1](https://github.com/codsen/codsen/commit/aee27c1346fce279f7f2570c245469bafcaa72a5))
|
|
11
|
+
|
|
12
|
+
## 1.2.0 (2022-12-27)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- add `isCurrencyChar()` ([3de83c3](https://github.com/codsen/codsen/commit/3de83c3edf31c503bf394887b64915d3d74ed185))
|
|
17
|
+
- add `isCurrencySymbol()` ([9de553c](https://github.com/codsen/codsen/commit/9de553c30c2dbbc570409b876dde8161ac2ae693))
|
|
18
|
+
|
|
19
|
+
## 1.1.1 (2022-12-27)
|
|
7
20
|
|
|
8
21
|
### Bug Fixes
|
|
9
22
|
|
|
10
23
|
- add multiplication sign ([a93a230](https://github.com/codsen/codsen/commit/a93a2302d2385cc32f2cea0825666b683b4402e0))
|
|
11
24
|
|
|
12
|
-
|
|
25
|
+
## 1.1.0 (2022-12-26)
|
|
13
26
|
|
|
14
27
|
### Features
|
|
15
28
|
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2023 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -52,6 +52,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
52
52
|
|
|
53
53
|
MIT License.
|
|
54
54
|
|
|
55
|
-
Copyright © 2010-
|
|
55
|
+
Copyright © 2010-2023 Roy Revelt and other contributors.
|
|
56
56
|
|
|
57
57
|
<p align="center"><img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center"></p>
|
package/dist/codsen-utils.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name codsen-utils
|
|
3
3
|
* @fileoverview Various utility functions
|
|
4
|
-
* @version 1.
|
|
4
|
+
* @version 1.3.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
|
|
10
|
+
var s="1.3.0";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};
|
package/dist/codsen-utils.umd.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name codsen-utils
|
|
3
3
|
* @fileoverview Various utility functions
|
|
4
|
-
* @version 1.
|
|
4
|
+
* @version 1.3.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
|
|
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.0";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);})();
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -16,7 +16,12 @@ 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;
|
|
21
|
+
}
|
|
19
22
|
declare function isNumberChar(value: unknown): boolean;
|
|
23
|
+
declare function isCurrencyChar(value: unknown): boolean;
|
|
24
|
+
declare function isCurrencySymbol(value: unknown): boolean;
|
|
20
25
|
declare function isLetter(value: unknown): boolean;
|
|
21
26
|
declare function isLatinLetter(value: unknown): boolean;
|
|
22
27
|
declare function isQuote(value: unknown): boolean;
|
|
@@ -45,6 +50,11 @@ declare function stringSplice(
|
|
|
45
50
|
count?: number,
|
|
46
51
|
add?: string
|
|
47
52
|
): string;
|
|
53
|
+
declare function isStr(something: unknown): something is string;
|
|
54
|
+
declare function isNum(something: unknown): something is number;
|
|
55
|
+
declare function isInt(something: unknown): something is number;
|
|
56
|
+
declare function isBool(something: unknown): something is boolean;
|
|
57
|
+
declare function isNull(something: unknown): something is null;
|
|
48
58
|
/**
|
|
49
59
|
* Gives array of indexes of all found substring occurrences
|
|
50
60
|
* @param string source string
|
|
@@ -55,28 +65,54 @@ declare function stringSplice(
|
|
|
55
65
|
* -> [0, 3, 4, 7]
|
|
56
66
|
*/
|
|
57
67
|
declare function findAllIdx(value: unknown, substring: unknown): number[];
|
|
68
|
+
/**
|
|
69
|
+
* Unlike lodash equivalent, it does not mutate the input array
|
|
70
|
+
* @param input
|
|
71
|
+
* @param remove
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
declare function pullAll<T, U>(input?: T[], remove?: U[]): T[];
|
|
75
|
+
declare function existy(x: unknown): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Returns a shallow copy of input array, with only unique elements
|
|
78
|
+
* @param input array
|
|
79
|
+
* @returns de-duped array
|
|
80
|
+
*/
|
|
81
|
+
declare function uniq<T>(input: T[]): T[];
|
|
82
|
+
declare function hasOwnProp(obj: unknown, prop: string): boolean;
|
|
58
83
|
declare const voidTags: string[];
|
|
59
84
|
declare const inlineTags: Set<string>;
|
|
60
85
|
|
|
61
86
|
export {
|
|
87
|
+
Obj,
|
|
62
88
|
backslash,
|
|
63
89
|
backtick,
|
|
64
90
|
doublePrime,
|
|
65
91
|
ellipsis,
|
|
92
|
+
existy,
|
|
66
93
|
findAllIdx,
|
|
67
94
|
hairspace,
|
|
95
|
+
hasOwnProp,
|
|
68
96
|
inlineTags,
|
|
97
|
+
isBool,
|
|
98
|
+
isCurrencyChar,
|
|
99
|
+
isCurrencySymbol,
|
|
100
|
+
isInt,
|
|
69
101
|
isLatinLetter,
|
|
70
102
|
isLetter,
|
|
71
103
|
isLowercaseLetter,
|
|
104
|
+
isNull,
|
|
105
|
+
isNum,
|
|
72
106
|
isNumberChar,
|
|
73
107
|
isPlainObject,
|
|
74
108
|
isQuote,
|
|
109
|
+
isStr,
|
|
75
110
|
isUppercaseLetter,
|
|
76
111
|
isWhitespaceChar,
|
|
77
112
|
leftDoubleQuote,
|
|
78
113
|
leftSingleQuote,
|
|
79
114
|
multiplicationSign,
|
|
115
|
+
pullAll,
|
|
80
116
|
punctuationChars,
|
|
81
117
|
rawMDash,
|
|
82
118
|
rawNDash,
|
|
@@ -88,6 +124,7 @@ export {
|
|
|
88
124
|
singlePrime,
|
|
89
125
|
stringSplice,
|
|
90
126
|
thinSpace,
|
|
127
|
+
uniq,
|
|
91
128
|
version,
|
|
92
129
|
voidTags,
|
|
93
130
|
};
|