stringweaver 1.0.6 → 1.0.7
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/Bundle/index.min.js +4 -4
- package/package.json +2 -2
- package/src/extensions.js +43 -41
package/Bundle/index.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*© KooiInc 2025-2030*/
|
|
2
|
-
var
|
|
3
|
-
RegExp error message: "${r.message}"`}}u(
|
|
4
|
-
`).map(o=>o.replace(/\s|\/\/.*$/g,"").trim().replace(/(@s!)/g," ")).join(""),r)}u(
|
|
2
|
+
var B=Object.defineProperty,pe=Object.defineProperties;var me=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var z=Math.pow,T=(e,t,r)=>t in e?B(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,p=(e,t)=>{for(var r in t||(t={}))de.call(t,r)&&T(e,r,t[r]);if(_)for(var r of _(t))he.call(t,r)&&T(e,r,t[r]);return e},m=(e,t)=>pe(e,me(t)),u=(e,t)=>B(e,"name",{value:t,configurable:!0});var P=be();function be(e=""){return e=(e==null?void 0:e.constructor)===String?e:"",function(s,...h){return L(s,I(h))};function t(s,h){return h&&e.length>0?String(e):`{${s}}`}u(t,"invalidate");function r(s){return(s==null?void 0:s.constructor)===String||(s==null?void 0:s.constructor)===Number&&!Number.isNaN(s)}u(r,"isStringOrNumber");function n(s,h){let $=s in h;return $&&r(h[s])?String(h[s]):t(s,$)}u(n,"replacement");function o(s){return(...h)=>{let $=h.find(g=>g.key);return n($?$.key:"_",s)}}u(o,"getReplacerLambda");function a(s,h){return s.replace(new RegExp("\\{(?<key>[a-z_\\d]+)}","gim"),o(h))}u(a,"replace");function l(s){let h=[];return Object.entries(s).forEach(([$,g])=>{g.forEach((U,c)=>{var d;return(d=h[c])!=null||(h[c]={}),h[c][$]=U})}),h}u(l,"convertTokensFromArrayValues");function S(s){return s.length===1&&Object.values(s[0]).every(Array.isArray)}u(S,"isMultiLineWithArrays");function I(s){return S(s)?l(s[0]):s}u(I,"processTokens");function L(s,h){return h!=null&&h.length?h.filter($=>$).map($=>($==null?void 0:$.constructor)===Object?a(s,$):"").join(""):s}u(L,"interpolate")}u(be,"interpolateFactory");var{randomString:M,uuid4:Y}=Se();function Se(){let e=g(),t=u(()=>e?[...crypto.getRandomValues(new Uint32Array(1))].shift()/z(2,32):Math.random(),"getRandomValue"),r=u(({min:i=0,max:f=Number.MAX_SAFE_INTEGER}={})=>Math.floor(t()*(f-i+1)+i),"randomNr"),n=u((i=0,f=10,y)=>(y||[])instanceof Function?[...Array(f)].map((x,A)=>i+A).map(y):[...Array(f)].map((x,A)=>i+A),"range"),o=u(i=>String.fromCharCode(i),"map2Chrs"),a="!?@#$%^&*=+_;-".split(""),l=RegExp(`[${a.map(i=>`\\${i}`).join("")}]`,"g"),S=u(i=>{let f=i.length;for(;f--;){let y=r({max:f});[i[f],i[y]]=[i[y],i[f]]}return i},"shuffle"),I=S(n(65,26,o)),L=S(n(97,26,o)),h={UCLC:S(I.concat(L)),UC:I,LC:L,Nrs:S(n()),Sym:S(a)},$=u(i=>Object.entries(i).reduce((f,[y,x])=>x?[...f,...h[y]]:f,L),"getChars2Use");function g(){try{return window&&"crypto"in window}catch(i){return!1}}u(g,"checkBrowserCrypto");function U(){return e&&crypto.randomUUID?crypto.randomUUID():[...new Uint8Array(16)].map(i=>r({max:255})).map((i,f)=>`${(f===8?i&63|128:f===6?i&15|64:i).toString(16).padStart(2,"0")}${~[3,5,7,9].indexOf(f)?"-":""}`).join("")}u(U,"uuid4");function c(i,f,y){return/[a-z]/i.test(i)&&(f&&y?/\d/.test(i)&&l.test(i):f?/\d/.test(i):y?l.test(i):!0)}u(c,"strTest");function d(i){let f=[...i],y=f.findIndex(x=>/[a-z]/i.test(x));return[f[0],f[y]]=[f[y],f[0]],f.join("")}u(d,"alphaSwap");function w({len:i=12,includeUppercase:f=!0,includeNumbers:y,includeSymbols:x,startAlphabetic:A}={}){i=i<6?6:i;let O=S($({UC:f,Nrs:y,Sym:x}));for(;O.length<i;)O=[...O,...S(O)];let G=O.slice(0,i).join("");if(!(y||x))return G;for(let Z=0;Z<O.length;Z+=1)if(G=O.slice(Z,Z+i).join(""),c(G,y,x))return A&&!/^[a-z]/i.test(G)?d(G):G;return w({len:i,includeUppercase:f,includeNumbers:y,includeSymbols:x,startAlphabetic:A})}return u(w,"randomString"),{randomString:w,uuid4:U}}u(Se,"randomStringGeneratorFactory");var X=ye;function ye(e,...t){t=e.raw?t:[t];try{return we(e,...t)}catch(r){let n=J();return`Error creating Regular Expression from string "${e.raw||e}" with flags ${n}
|
|
3
|
+
RegExp error message: "${r.message}"`}}u(ye,"createRegExp");function J(...e){return e.length>0?Array.isArray(e.slice(-1))?e.pop().join(""):e.join(""):""}u(J,"resolveFlags");function we(e,...t){let r=J(...t);t=[];let n=e.raw||[e];return new RegExp((t.length&&n.reduce((o,a,l)=>o.concat(t[l-1]||"").concat(a),"")||(n==null?void 0:n.join(""))).split(`
|
|
4
|
+
`).map(o=>o.replace(/\s|\/\/.*$/g,"").trim().replace(/(@s!)/g," ")).join(""),r)}u(we,"regExp");function Q(e,...t){return e!=null&&e.raw?String.raw({raw:e},...t):b(e).length?e:""}u(Q,"resolveTemplateString");function b(e){return(e==null?void 0:e.value)||(e==null?void 0:e.constructor)===String&&e||""}u(b,"getStringValue");function Ce(e,t,r){return e===String&&r?(t==null?void 0:t.constructor)!==R&&(t==null?void 0:t.constructor)!==e:(t==null?void 0:t.constructor)!==e}u(Ce,"checkType");function N(e,t,r=!0){return Array.isArray(t)&&t.length>0&&!t.find(n=>Ce(e,n,r))}u(N,"isArrayOf");function V(e){return(e==null?void 0:e.constructor)===Number&&!Number.isNaN(e)}u(V,"isNumber");function $e(e){let t=j(xe());return t.value.split(/\n/).concat(Object.entries(Object.getOwnPropertyDescriptors(t)).map(([r,n])=>{if(r==="quote")return"quote (Object. See [constructor].quoteInfo)";let o=!e.find(a=>a===r);return`${r} (${r==="value"?"getter/setter":r==="clone"?"chainable getter":r==="notEmpty"?"chainable getter|undefined":r in String.prototype?`${n.get?"getter":"method"} (override)`:n.value&&n.value.constructor===Function?o?`chainable method${r in W?" *custom*":""}`:"method":n.value?"property":n.get?o?`chainable getter${r in W?" *custom*":""}`:"getter":"-"})`}).sort((r,n)=>r.localeCompare(n)))}u($e,"getSWInformation");function K(e,t){let r="constructor,history,indexOf,toString,value,valueOf,empty".split(",");return Object.defineProperties(e,{constructor:{get(){return e},enumerable:!1},format:{value(n,...o){return j(n).format(...o)}},addCustom:{value({name:n,method:o,enumerable:a=!1,isGetter:l=!1}={}){if(j``[n])return console.error(`addCustom: the property "${n}" exists and can not be redefined`);(n==null?void 0:n.constructor)===String&&(o==null?void 0:o.constructor)===Function&&o.length>0&&(t[n]={method:o,enumerable:a,isGetter:l})}},info:{get(){return $e(r)}},keys:{get(){return Object.keys(Object.getOwnPropertyDescriptors(j``)).sort((n,o)=>n.localeCompare(o)).map(n=>!/constructor|toString|valueOf/.test(n)&&n in t?`${n} *custom*`:n)}},quoteInfo:{get(){let n=p({},q());return delete n.re,Object.entries(n).sort((o,a)=>o[0].localeCompare(a[0])).reduce((o,[a,l])=>{let S=l.constructor===Function?"(start:string[, end:string])":` (${l.join(" [instance value] ")})`;return[...o,`[instance].quote.${a}${S}`]},[])}},uuid4:{get(){return j(Y())}},randomString:{value:u(function({len:n,includeUppercase:o,includeNumbers:a,includeSymbols:l,startAlphabetic:S}={}){return j(M({len:n,includeUppercase:o,includeNumbers:a,includeSymbols:l,startAlphabetic:S}))},"value")},regExp:{value:X}}),e}u(K,"createExtendedCTOR");function k(e,t){return new RegExp(e.replace(new RegExp("\\p{S}|\\p{P}","gu"),r=>`\\${r}`),t)}u(k,"escapeRE");function xe(){return atob`Rm9yIHRoZSByZWNvcmQ6CltjbV0gY2hhaW5hYmxlIGdldHRlcnMvbWV0aG9kcyBtb2RpZnkgdGhlIGluc3RhbmNlIHN0cmluZwpbY21dIGluZGV4T2Ygb3ZlcnJpZGVzIHJldHVybiBbdW5kZWZpbmVkXSBpZiBub3RoaW5nIHdhcyBmb3VuZCAoc28gb25lIGNhbiB1c2UgW2xhc3RJXWluZGV4T2YoW3NvbWUgc3RyaW5nIHZhbHVlXSkgPz8gMApbY21dIGluY2x1ZGVzIGluZm9ybWF0aW9uIGZvciBjdXN0b20gbWV0aG9kcy9nZXR0ZXJzIGlmIGFwcGxpY2FibGU=`.replace(/\[cm\]/g,"\u2714")}u(xe,"decode");function q(){let t={backtick:["`","`"],bracket:["{","}"],curlyDoubleInward:["\u201D","\u201C"],curlyDouble:["\u201C","\u201D"],curlyDoubleEqual:["\u201C","\u201C"],curlyLHDouble:["\u201E","\u201D"],curlyLHDoubleInward:["\u201E","\u201C"],curlyLHSingle:["\u201A","\u2019"],curlyLHSingleInward:["\u201A","\u2018"],curlySingle:["\u201B","\u2019"],curlySingleEqual:["\u201B","\u201B"],curlySingleInward:["\u2019","\u201B"],custom:u((n,o)=>(n=b(n),o=b(o),[b(n),o.length?o:n]),"custom"),double:['"','"'],guillemets:["\xAB","\xBB"],guillemetsInward:["\xBB","\xAB"],guillemetsSingle:["\u2039","\u203A"],guillemetsSingleInward:["\u203A","\u2039"],single:["'","'"],squareBrackets:["[","]"]},r=Object.values(t).filter(n=>Array.isArray(n)).map(n=>n.map(o=>`\\${o}`).join("")).join("");return t.re=RegExp(`^[${r}]|[${r}]$`,"g"),t}u(q,"defineQuotingStyles");var C=q();function E(e,t,r){return e=b(e),e.length>0?t(e):r||e}u(E,"checkAndRun");function D(e,...t){return E(e,()=>`${P(e,...t)}`)}u(D,"format");function v(e){return E(e,()=>`${e[0].toUpperCase()}${e.slice(1)}`)}u(v,"ucFirst");function ee(e,t,r){return!t&&!r?e:([t,r]=N(String,[t,r!=null?r:""])?[t,r]:["",""],`${t}${e}${r||t}`)}u(ee,"surroundWith");function te(e){return E(e,()=>e.replace(/\s/g,"").replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`).replace(/-{2,}/g,"-").replace(/[^a-z-]/g,"").replace(/^-|-$/,""))}u(te,"toDashedNotation");function re(e){return E(e,()=>e.replace(/\s/g,"").replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`).replace(/_{2,}/g,"_").replace(/[^a-z_]/g,"").replace(/^_|_$/,""))}u(re,"toSnakeCase");function ne(e){return E(e,()=>[...e.toLowerCase()].slice(1).reduce((t,r)=>t+(new RegExp("\\p{L}|[-']","u").test(t.at(-1))?r.toLowerCase():r.toUpperCase()),e[0].toUpperCase()))}u(ne,"wordsFirstUp");function oe(e){return E(e,()=>e.toLowerCase().trim().split(/[- ]/).filter(t=>t&&t.length>0).map((t,r)=>r>0&&`${v(t)}`||t).join(""))}u(oe,"toCamelcase");function ue(e,{at:t,html:r=!1,wordBoundary:n=!1}={}){return E(e,()=>{var S,I;if(e.length<=t)return e;let o=e.slice(0,t-1),a=r?"…":"...",l=n&&(I=(S=[...o.matchAll(new RegExp("\\p{Pe}|\\p{Z}","gu"))].at(-1))==null?void 0:S.index)!=null?I:o.length;return(n?o.slice(0,l+1).trim():o)+a})}u(ue,"truncate");function H(e,t){return E(e,()=>{let r=e.split(/\n/).map(n=>n.trim().replace(/\s{2,}/g," "));return t?r.join(`
|
|
5
5
|
`):r.filter(n=>n.length>0).join(`
|
|
6
|
-
`)})}u(
|
|
6
|
+
`)})}u(H,"trimAll");function ce(e,{replacements:t={},caseSensitive:r=!1}={}){e=b(e);let n=Object.entries(t).flat(),o=N(String,n)&&(r==null?void 0:r.constructor)===Boolean,a=`g${r?"":"i"}`;if(o&&(n=n.map(l=>b(l)).filter(l=>n.length>0),n.length))for(;n.length;){let[l,S]=[n.shift(),n.shift()],I=k(l,a);e=e.replace(I,S)}return e}u(ce,"replaceWords");function le(e,t,r){e=b(e),r=V(r)?r:0;let n=e.indexOf(t,r||0);return n<0?void 0:n}u(le,"indexOf");function ae(e,t,r){e=b(e),r=V(r)?r:e.length;let n=e.lastIndexOf(t,r);return n<0?void 0:n}u(ae,"lastIndexOf");function F(e,{value:t,values:r,at:n=0}={}){e=b(e),n=V(n)?n:0;let o=b(r);return r=b(t).length?t:o.length?o:N(String,r)?r.map(a=>b(a)).join(""):[],r.length<=1?e:e.length===0?`${r}${e}`:`${e.slice(0,n)}${r}${e.slice(n)}`}u(F,"insert");function ie(e,...t){return t=N(String,t)&&t,t?F(b(e),{values:t,at:0}):b(e)}u(ie,"prefix");function se(e,...t){return t=N(String,t)&&t,t&&t.length>0?`${b(e)}`.concat(t.join("")):b(e)}u(se,"append");function fe(e,t){return{value:{get backtick(){return e.enclose(...C.backtick)},get bracket(){return e.enclose(...C.bracket)},get curlyDouble(){return e.enclose(...C.curlyDouble)},get curlyDoubleInward(){return e.enclose(...C.curlyDoubleInward)},get curlyDoubleEqual(){return e.enclose(...C.curlyDoubleEqual)},get curlyLHDoubleInward(){return e.enclose(...C.curlyLHDoubleInward)},get curlyLHSingle(){return e.enclose(...C.curlyLHSingle)},get curlyLHSingleInward(){return e.enclose(...C.curlyLHSingleInward)},get curlySingle(){return e.enclose(...C.curlySingle)},get curlySingleEqual(){return e.enclose(...C.curlySingleEqual)},get curlySingleInward(){return e.enclose(...C.curlySingleInward)},custom(r,n){return e.enclose(r,n!=null?n:r)},get double(){return e.enclose(...C.double)},get guillemets(){return e.enclose(...C.guillemets)},get guillemetsInward(){return e.enclose(...C.guillemetsInward)},get guillemetsSingle(){return e.enclose(...C.guillemetsSingle)},get guillemetsSingleInward(){return e.enclose(...C.guillemetsSingleInward)},get remove(){return t(`${e.value.replace(C.re,"")}`)},get single(){return e.enclose(...C.single)},get squareBrackets(){return e.enclose(...C.squareBrackets)}},enumerable:!1}}u(fe,"quotGetters");var ge=Ie;function Ie({initialstring:e,customMethods:t}={}){let r={},n=new Proxy(r,S(r)),o=(e==null?void 0:e.constructor)===String?e:"",a=[o],l={configurable:!1,enumerable:!1};return Object.defineProperties(r,{append:m(p({},l),{value(...c){return g(se(o,...c))}}),enclose:m(p({},l),{value(c,d){return g(ee(o,c,d))}}),format:m(p({},l),{value(...c){return g(D(o,...c))}}),indexOf:m(p({},l),{value(c){return le(o,c)}}),interpolate:m(p({},l),{value(...c){return g(D(o,...c))}}),insert:m(p({},l),{value({value:c,values:d,at:w}={}){return g(F(o,{value:c,values:d,at:w}))}}),lastIndexOf:m(p({},l),{value(c){return ae(o,c)}}),prefix:m(p({},l),{value(...c){return g(ie(o,...c))}}),replaceWords:m(p({},l),{value({caseSensitive:c=!1,replacements:d={}}={}){return g(ce(o,{replacements:d,caseSensitive:c}))}}),toString:m(p({},l),{value(){return o}}),truncate:m(p({},l),{value({at:c,html:d=!1,wordBoundary:w=!1}={}){return g(ue(o,{at:c,html:d,wordBoundary:w}))}}),valueOf:m(p({},l),{value(){return o}}),undoLast:m(p({},l),{value(c){return h(c)}}),camelCase:m(p({},l),{get(){return g(oe(b(o)))}}),clone:m(p({},l),{get(){return I()}}),constructor:m(p({},l),{get(){return j.constructor}}),firstUp:m(p({},l),{get(){return g(v(b(o)))}}),history:m(p({},l),{get(){return a},set(c){a=c}}),empty:m(p({},l),{get(){return o.length<1}}),notEmpty:m(p({},l),{get(){return o.length<1?void 0:n}}),kebabCase:m(p({},l),{get(){return g(te(b(o)))}}),quote:fe(n,g),snakeCase:m(p({},l),{get(){return g(re(b(o)))}}),trimAll:m(p({},l),{get(){return g(H(o))}}),trimAllKeepLF:m(p({},l),{get(){return g(H(o,!0))}}),undoAll:m(p({},l),{get(){return s()}}),undo:m(p({},l),{get(){return $()}}),wordsUCFirst:m(p({},l),{get(){return g(ne(b(o)))}}),value:m(p({},l),{get(){return o},set(c){let d=b(c);d.length&&(o=d,a.push(d))}})}),U(t),Object.freeze(n);function S(c){return{get(d,w){return w in c?c[w]:w in String.prototype?L(w):void 0}}}u(S,"getTraps");function I(){let c=j(o);return c.history=[...a],c}u(I,"clone");function L(c){return o[c]instanceof Function?function(...d){let w=o[c](...d);return(w==null?void 0:w.constructor)===String?g(o[c](...d)):w}:o[c]}u(L,"wrapNative");function s(){for(;a.length>1;)a.pop();return o=a.at(-1),g(o,!1)}u(s,"undoAll");function h(c){if(!V(c))return g(o,!1);let d=a.length;return c>=d||c<1?(a=a.slice(0,1),o=a.at(-1),g(a.at(-1),!1)):(a=a.slice(0,d-c),o=a.at(-1),g(o,!1))}u(h,"undoSteps");function $(){return a.length===1?g(a[0]):(a.pop(),o=a.at(-1),g(o,!1))}u($,"undoLast");function g(c,d=!0){return o!==c&&d&&a.push(c),o=c,n}u(g,"wrap");function U(c){Object.entries(c).forEach(([d,w])=>{let{enumerable:i,method:f,isGetter:y}=w,x=!1;Object.defineProperty(r,d,y?{get(){return g(f(n).value)},enumerable:i,configurable:x}:{value(...O){return g(f(n,...O).value)},enumerable:i,configurable:x})})}u(U,"injectCustomMethods")}u(Ie,"instanceCreator");var W={},j=K(R,W);function R(e,...t){return ge({initialstring:Q(e,...t),customMethods:W})}u(R,"CustomStringConstructor");export{R as CustomStringConstructor,W as customMethods,j as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stringweaver",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.7",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/KooiInc/js-stringweaver"
|
|
22
|
+
"url": "git+https://github.com/KooiInc/js-stringweaver.git"
|
|
23
23
|
},
|
|
24
24
|
"bugs": {
|
|
25
25
|
"url": "https://github.com/KooiInc/js-stringweaver/issues"
|
package/src/extensions.js
CHANGED
|
@@ -13,53 +13,54 @@ function instanceCreator({initialstring, customMethods} = {}) {
|
|
|
13
13
|
let instance = new Proxy(customStringExtensions, getTraps(customStringExtensions));
|
|
14
14
|
let actualValue = initialstring?.constructor === String ? initialstring : ``;
|
|
15
15
|
let history = [actualValue];
|
|
16
|
-
const
|
|
16
|
+
const descriptorProps = {configurable: false, enumerable: false};
|
|
17
17
|
|
|
18
|
-
Object.defineProperties(customStringExtensions, {
|
|
19
|
-
append: { value(...strings) { return wrap(append(actualValue, ...strings)); }
|
|
20
|
-
enclose: { value(start, end) { return wrap(surroundWith(actualValue, start, end)); }
|
|
21
|
-
format: { value(...tokens) { return wrap(format(actualValue, ...tokens)); }
|
|
22
|
-
indexOf: { value(str) { return indexOf(actualValue, str); }
|
|
23
|
-
interpolate: { value(...tokens) { return wrap(format(actualValue, ...tokens)); }
|
|
24
|
-
insert: { value({ value, values, at } = {}) {
|
|
18
|
+
Object.defineProperties( customStringExtensions, {
|
|
19
|
+
append: { ...descriptorProps, value(...strings) { return wrap(append(actualValue, ...strings)); } },
|
|
20
|
+
enclose: { ...descriptorProps, value(start, end) { return wrap(surroundWith(actualValue, start, end)); } },
|
|
21
|
+
format: { ...descriptorProps, value(...tokens) { return wrap(format(actualValue, ...tokens)); } },
|
|
22
|
+
indexOf: { ...descriptorProps, value(str) { return indexOf(actualValue, str); } },
|
|
23
|
+
interpolate: { ...descriptorProps, value(...tokens) { return wrap(format(actualValue, ...tokens)); } },
|
|
24
|
+
insert: { ...descriptorProps, value({ value, values, at } = {}) {
|
|
25
25
|
return wrap(insert(actualValue, { value, values, at }));
|
|
26
|
-
}
|
|
26
|
+
}
|
|
27
27
|
},
|
|
28
|
-
lastIndexOf: { value(str) { return lastIndexOf(actualValue, str); }
|
|
29
|
-
prefix: { value(...strings) { return wrap(prefix(actualValue, ...strings)); }
|
|
30
|
-
replaceWords: { value({caseSensitive = false, replacements = {}} = {}) {
|
|
28
|
+
lastIndexOf: { ...descriptorProps, value(str) { return lastIndexOf(actualValue, str); } },
|
|
29
|
+
prefix: { ...descriptorProps, value(...strings) { return wrap(prefix(actualValue, ...strings)); } },
|
|
30
|
+
replaceWords: { ...descriptorProps, value({caseSensitive = false, replacements = {}} = {}) {
|
|
31
31
|
return wrap(replaceWords(actualValue, {replacements, caseSensitive}));
|
|
32
|
-
}
|
|
33
|
-
toString: { value() { return actualValue; }
|
|
34
|
-
truncate: { value({at, html = false, wordBoundary = false} = {}) {
|
|
35
|
-
return wrap(truncate(actualValue, {at, html, wordBoundary})); }
|
|
36
|
-
valueOf: { value() { return actualValue; }
|
|
37
|
-
undoLast: { value(nSteps) { return undoSteps(nSteps); }
|
|
32
|
+
} },
|
|
33
|
+
toString: { ...descriptorProps, value() { return actualValue; } },
|
|
34
|
+
truncate: { ...descriptorProps, value({at, html = false, wordBoundary = false} = {}) {
|
|
35
|
+
return wrap(truncate(actualValue, {at, html, wordBoundary})); } },
|
|
36
|
+
valueOf: { ...descriptorProps, value() { return actualValue; } },
|
|
37
|
+
undoLast: { ...descriptorProps, value(nSteps) { return undoSteps(nSteps); } },
|
|
38
38
|
|
|
39
|
-
camelCase: { get() { return wrap(toCamelcase(getStringValue(actualValue))); }
|
|
40
|
-
clone: { get() { return clone(); }
|
|
41
|
-
constructor: { get() { return $S.constructor; }
|
|
42
|
-
firstUp: { get() { return wrap(ucFirst(getStringValue(actualValue))); }
|
|
43
|
-
history: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
empty: { get() { return actualValue.length < 1; } },
|
|
48
|
-
notEmpty: { get() { return actualValue.length < 1 ? undefined: instance; } },
|
|
49
|
-
kebabCase: { get() { return wrap(toDashedNotation(getStringValue(actualValue))); }, enumerable, configurable },
|
|
39
|
+
camelCase: { ...descriptorProps, get() { return wrap(toCamelcase(getStringValue(actualValue))); } },
|
|
40
|
+
clone: { ...descriptorProps, get() { return clone(); } },
|
|
41
|
+
constructor: { ...descriptorProps, get() { return $S.constructor; } },
|
|
42
|
+
firstUp: { ...descriptorProps, get() { return wrap(ucFirst(getStringValue(actualValue))); } },
|
|
43
|
+
history: { ...descriptorProps, get() { return history; }, set(value) { history = value; } },
|
|
44
|
+
empty: { ...descriptorProps, get() { return actualValue.length < 1; } },
|
|
45
|
+
notEmpty: { ...descriptorProps, get() { return actualValue.length < 1 ? undefined: instance; } },
|
|
46
|
+
kebabCase: { ...descriptorProps, get() { return wrap(toDashedNotation(getStringValue(actualValue))); } },
|
|
50
47
|
quote: quotGetters(instance, wrap),
|
|
51
|
-
snakeCase: { get() { return wrap(toSnakeCase(getStringValue(actualValue))); } },
|
|
52
|
-
trimAll: { get() { return wrap(trimAll(actualValue)); }
|
|
53
|
-
trimAllKeepLF: { get() { return wrap(trimAll(actualValue, true)); }
|
|
54
|
-
undoAll: { get() { return undoAll(); }
|
|
55
|
-
undo: { get() { return undoLast(); }
|
|
56
|
-
wordsUCFirst: { get() { return wrap(wordsFirstUp(getStringValue(actualValue))); }
|
|
57
|
-
value: {
|
|
48
|
+
snakeCase: { ...descriptorProps, get() { return wrap(toSnakeCase(getStringValue(actualValue))); } },
|
|
49
|
+
trimAll: { ...descriptorProps, get() { return wrap(trimAll(actualValue)); } },
|
|
50
|
+
trimAllKeepLF: { ...descriptorProps, get() { return wrap(trimAll(actualValue, true)); } },
|
|
51
|
+
undoAll: { ...descriptorProps, get() { return undoAll(); } },
|
|
52
|
+
undo: { ...descriptorProps, get() { return undoLast(); } },
|
|
53
|
+
wordsUCFirst: { ...descriptorProps, get() { return wrap(wordsFirstUp(getStringValue(actualValue))); } },
|
|
54
|
+
value: { ...descriptorProps,
|
|
58
55
|
get() { return actualValue; },
|
|
59
|
-
set(value) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
set(value) {
|
|
57
|
+
const nwValue = getStringValue(value);
|
|
58
|
+
if (nwValue.length) {
|
|
59
|
+
actualValue = nwValue;
|
|
60
|
+
history.push(nwValue);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
63
64
|
});
|
|
64
65
|
|
|
65
66
|
injectCustomMethods(customMethods);
|
|
@@ -136,9 +137,10 @@ function instanceCreator({initialstring, customMethods} = {}) {
|
|
|
136
137
|
function injectCustomMethods(customMethods) {
|
|
137
138
|
Object.entries(customMethods).forEach(([methodName, methodContainer]) => {
|
|
138
139
|
const {enumerable, method, isGetter} = methodContainer;
|
|
140
|
+
const configurable = false
|
|
139
141
|
const descriptor = isGetter
|
|
140
142
|
? { get() { return wrap(method(instance).value); }, enumerable, configurable }
|
|
141
|
-
: { value(...args) { return wrap(method(instance, ...args).value); }, enumerable, };
|
|
143
|
+
: { value(...args) { return wrap(method(instance, ...args).value); }, enumerable, configurable };
|
|
142
144
|
|
|
143
145
|
Object.defineProperty(customStringExtensions, methodName, descriptor);
|
|
144
146
|
});
|