@jsarc/qust 0.0.1-beta.0.2 → 0.0.1-beta.0.4

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/index.ts CHANGED
@@ -366,11 +366,6 @@ const globalFunct = (function() {
366
366
 
367
367
  const __bundledModules = globalFunctModule;
368
368
 
369
- if (typeof exports !== 'undefined') {
370
- exports.default = qust;
371
- exports.Qust = Qust;
372
- exports.qust = qust;
373
- }
374
369
  return globalFunctModule;
375
370
 
376
371
  })();
package/js/index.js CHANGED
@@ -272,11 +272,6 @@ const globalFunct = (function () {
272
272
  qust: qust,
273
273
  };
274
274
  const __bundledModules = globalFunctModule;
275
- if (typeof exports !== 'undefined') {
276
- exports.default = qust;
277
- exports.Qust = Qust;
278
- exports.qust = qust;
279
- }
280
275
  return globalFunctModule;
281
276
  })();
282
277
  const QustElementGF = globalFunct.Qust;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.1-beta.0.2",
6
+ "version": "0.0.1-beta.0.4",
7
7
  "description": "Qust est une bibliothèque TypeScript ultra-légère et performante pour la sérialisation et désérialisation d'objets en chaînes de requête (query strings). Elle offre une API simple et puissante pour manipuler les paramètres d'URL avec support des types complexes, des tableaux, des objets imbriqués et des options avancées.",
8
8
  "main": "index.ts",
9
9
  "keywords": [],
package/web/qust.js CHANGED
@@ -281,11 +281,6 @@ const globalFunct = (function () {
281
281
  qust: qust,
282
282
  };
283
283
  const __bundledModules = globalFunctModule;
284
- if (typeof exports !== 'undefined') {
285
- exports.default = qust;
286
- exports.Qust = Qust;
287
- exports.qust = qust;
288
- }
289
284
  return globalFunctModule;
290
285
  })();
291
286
  const QustElementGF = globalFunct.Qust;
package/web/qust.min.js CHANGED
@@ -1 +1 @@
1
- let globalFunct=(()=>{let t={arrayFormat:"bracket",arraySeparator:",",skipNull:!0,skipEmptyString:!1,encode:!0,decode:!0,depth:10};class r{options;constructor(e={}){this.options={...t,...e}}stringify(e){return e&&"object"==typeof e&&(this.processObject("",e,e=[],0),0<e.length)?"?"+e.join("&"):""}parse(e){if(!e||"string"!=typeof e)return{};e=e.startsWith("?")?e.slice(1):e;if(!e)return{};var t,r,s,o={};for(t of e.split("&"))t&&([r,s]=t.split("="),r)&&(r=this.options.decode?decodeURIComponent(r):r,s=this.options.decode&&void 0!==s?decodeURIComponent(s):s,this.setValue(o,r,s));return this.transformArrays(o)}processObject(e,t,r,s){if(s>this.options.depth)console.warn("Qust: Profondeur maximale atteinte, arrêt de la récursion");else if(null==t)this.options.skipNull||r.push(this.encodeKey(e));else if("string"!=typeof t||""!==t||!this.options.skipEmptyString)if(Array.isArray(t))this.processArray(e,t,r,s+1);else if("object"!=typeof t||this.isPrimitive(t)){var o=this.encodeKey(e),n=(this.options.encode&&"string"==typeof t?encodeURIComponent:String)(t);r.push(o+"="+n)}else for(var[i,a]of Object.entries(t)){i=e?`${e}[${i}]`:i;this.processObject(i,a,r,s+1)}}processArray(r,e,s,o){if(0!==e.length){let t=this.encodeKey(r);switch(this.options.arrayFormat){case"comma":var n=e.map(e=>(this.options.encode&&"string"==typeof e?encodeURIComponent:String)(e)).join(this.options.arraySeparator);s.push(t+"="+n);break;case"index":e.forEach((e,t)=>{this.processObject(r+`[${t}]`,e,s,o)});break;case"separator":e.forEach(e=>{e=(this.options.encode&&"string"==typeof e?encodeURIComponent:String)(e);s.push(t+"="+e)});break;case"none":e.forEach(e=>{this.processObject(r,e,s,o)});break;default:e.forEach(e=>{this.processObject(r+"[]",e,s,o)})}}}encodeKey(t){if(!this.options.encode)return t;var r=[];let s="";for(let e=0;e<t.length;e++){var o=t[e];"["===o||"]"===o?(s&&(r.push(encodeURIComponent(s)),s=""),r.push(o)):s+=o}return s&&r.push(encodeURIComponent(s)),r.join("")}setValue(e,t,r){var s=t.match(/([^\[\]]+)|(\[\])/g);if(s){let t=e;for(let e=0;e<s.length;e++){var o,n,i=s[e],a=e===s.length-1;"[]"===i?(Array.isArray(t)||(t=[]),a?r&&t.push(this.parseValue(r)):(o=s[e+1],o=parseInt(o,10),isNaN(o)?(n={},t.push(n),t=n):(void 0===t[o]&&(t[o]={}),t=t[o],e++))):a?void 0!==r&&(t[i]=this.parseValue(r)):(void 0!==t[i]&&"object"==typeof t[i]||(n=s[e+1],t[i]="[]"===n?[]:{}),t=t[i])}}else void 0!==r&&(e[t]=this.parseValue(r))}transformArrays(s){if(Array.isArray(s))return s.map(e=>"object"==typeof e&&null!==e?this.transformArrays(e):e);if("object"!=typeof s||null===s)return s;let r={};var e=Object.keys(s);if(e.every(e=>{var t=parseInt(e,10);return!isNaN(t)&&0<=t&&t.toString()===e})&&0<e.length){let r=[];return e.forEach(e=>{var t=parseInt(e,10);r[t]=this.transformArrays(s[e])}),r}return e.forEach(e=>{var t=s[e];r[e]="object"==typeof t&&null!==t?this.transformArrays(t):t}),r}parseValue(e){var t;return"true"===e||"false"!==e&&("null"===e?null:"undefined"!==e?(t=Number(e),isNaN(t)||""===e.trim()?e:t):void 0)}isPrimitive(e){return null===e||"object"!=typeof e&&"function"!=typeof e}setOptions(e){this.options={...this.options,...e}}getOptions(){return{...this.options}}static exposeToGlobal(){"undefined"!=typeof window&&(window.Qust=r)}}var e={stringify(e,t){return new r(t).stringify(e)},parse(e,t){return new r(t).parse(e)}},s=("undefined"!=typeof window&&(window.Qust=r,window.qust=e),{default:e,Qust:r,qust:e});return"undefined"!=typeof exports&&(exports.default=e,exports.Qust=r,exports.qust=e),s})(),QustElementGF=globalFunct.Qust,qustElementGF=globalFunct.qust,defaultElementGF=globalFunct.default;
1
+ let globalFunct=(()=>{let t={arrayFormat:"bracket",arraySeparator:",",skipNull:!0,skipEmptyString:!1,encode:!0,decode:!0,depth:10};class r{options;constructor(e={}){this.options={...t,...e}}stringify(e){return e&&"object"==typeof e&&(this.processObject("",e,e=[],0),0<e.length)?"?"+e.join("&"):""}parse(e){if(!e||"string"!=typeof e)return{};e=e.startsWith("?")?e.slice(1):e;if(!e)return{};var t,r,s,o={};for(t of e.split("&"))t&&([r,s]=t.split("="),r)&&(r=this.options.decode?decodeURIComponent(r):r,s=this.options.decode&&void 0!==s?decodeURIComponent(s):s,this.setValue(o,r,s));return this.transformArrays(o)}processObject(e,t,r,s){if(s>this.options.depth)console.warn("Qust: Profondeur maximale atteinte, arrêt de la récursion");else if(null==t)this.options.skipNull||r.push(this.encodeKey(e));else if("string"!=typeof t||""!==t||!this.options.skipEmptyString)if(Array.isArray(t))this.processArray(e,t,r,s+1);else if("object"!=typeof t||this.isPrimitive(t)){var o=this.encodeKey(e),n=(this.options.encode&&"string"==typeof t?encodeURIComponent:String)(t);r.push(o+"="+n)}else for(var[i,a]of Object.entries(t)){i=e?`${e}[${i}]`:i;this.processObject(i,a,r,s+1)}}processArray(r,e,s,o){if(0!==e.length){let t=this.encodeKey(r);switch(this.options.arrayFormat){case"comma":var n=e.map(e=>(this.options.encode&&"string"==typeof e?encodeURIComponent:String)(e)).join(this.options.arraySeparator);s.push(t+"="+n);break;case"index":e.forEach((e,t)=>{this.processObject(r+`[${t}]`,e,s,o)});break;case"separator":e.forEach(e=>{e=(this.options.encode&&"string"==typeof e?encodeURIComponent:String)(e);s.push(t+"="+e)});break;case"none":e.forEach(e=>{this.processObject(r,e,s,o)});break;default:e.forEach(e=>{this.processObject(r+"[]",e,s,o)})}}}encodeKey(t){if(!this.options.encode)return t;var r=[];let s="";for(let e=0;e<t.length;e++){var o=t[e];"["===o||"]"===o?(s&&(r.push(encodeURIComponent(s)),s=""),r.push(o)):s+=o}return s&&r.push(encodeURIComponent(s)),r.join("")}setValue(e,t,r){var s=t.match(/([^\[\]]+)|(\[\])/g);if(s){let t=e;for(let e=0;e<s.length;e++){var o,n,i=s[e],a=e===s.length-1;"[]"===i?(Array.isArray(t)||(t=[]),a?r&&t.push(this.parseValue(r)):(o=s[e+1],o=parseInt(o,10),isNaN(o)?(n={},t.push(n),t=n):(void 0===t[o]&&(t[o]={}),t=t[o],e++))):a?void 0!==r&&(t[i]=this.parseValue(r)):(void 0!==t[i]&&"object"==typeof t[i]||(n=s[e+1],t[i]="[]"===n?[]:{}),t=t[i])}}else void 0!==r&&(e[t]=this.parseValue(r))}transformArrays(s){if(Array.isArray(s))return s.map(e=>"object"==typeof e&&null!==e?this.transformArrays(e):e);if("object"!=typeof s||null===s)return s;let r={};var e=Object.keys(s);if(e.every(e=>{var t=parseInt(e,10);return!isNaN(t)&&0<=t&&t.toString()===e})&&0<e.length){let r=[];return e.forEach(e=>{var t=parseInt(e,10);r[t]=this.transformArrays(s[e])}),r}return e.forEach(e=>{var t=s[e];r[e]="object"==typeof t&&null!==t?this.transformArrays(t):t}),r}parseValue(e){var t;return"true"===e||"false"!==e&&("null"===e?null:"undefined"!==e?(t=Number(e),isNaN(t)||""===e.trim()?e:t):void 0)}isPrimitive(e){return null===e||"object"!=typeof e&&"function"!=typeof e}setOptions(e){this.options={...this.options,...e}}getOptions(){return{...this.options}}static exposeToGlobal(){"undefined"!=typeof window&&(window.Qust=r)}}var e={stringify(e,t){return new r(t).stringify(e)},parse(e,t){return new r(t).parse(e)}};return"undefined"!=typeof window&&(window.Qust=r,window.qust=e),e={default:e,Qust:r,qust:e}})(),QustElementGF=globalFunct.Qust,qustElementGF=globalFunct.qust,defaultElementGF=globalFunct.default;