@jsarc/fodat 0.0.0 → 0.0.1-beta.0.2

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/README.md CHANGED
@@ -56,7 +56,7 @@ const { Fodat } = require('@jsarc/fodat');
56
56
  ```html
57
57
  <script src="@jsarc/fodat/fodat.all.js"></script>
58
58
  <script>
59
- // Disponible globalement comme window.Fodat
59
+ // Disponible globalement comme (window as any).Fodat
60
60
  const formData = new FormData();
61
61
  formData.append('user.name', 'John');
62
62
  const json = Fodat.transform(formData);
package/index.ts CHANGED
@@ -1,17 +1,9 @@
1
1
  // @ts-nocheck
2
2
 
3
- interface Window {
4
- default: typeof defaultElementGF;
5
- Fodat: any;
6
- __bundledModules: any;
7
- }
8
-
9
- const globalFunct = (function(global: any) {
3
+ const globalFunct = (function() {
10
4
  'use strict';
11
5
 
12
6
 
13
-
14
-
15
7
  class Fodat {
16
8
  static transform(formData: any): any {
17
9
  if(formData instanceof FormData) {
@@ -110,16 +102,6 @@ const globalFunct = (function(global: any) {
110
102
 
111
103
  return path;
112
104
  }
113
-
114
- static exposeToGlobal(): void {
115
- if (typeof window !== "undefined") {
116
- window.Fodat = Fodat;
117
- }
118
- }
119
- }
120
-
121
- if (typeof window !== "undefined") {
122
- window.Fodat = Fodat;
123
105
  }
124
106
 
125
107
 
@@ -133,29 +115,13 @@ const globalFunct = (function(global: any) {
133
115
 
134
116
  const __bundledModules = globalFunctModule;
135
117
 
136
- if (typeof global !== 'undefined') {
137
- (global as any).default = Fodat;
138
- (global as any).Fodat = Fodat;
139
- (global as any).__bundledModules = __bundledModules;
140
- }
141
-
142
- if (typeof window !== "undefined") {
143
- (window as any).default = Fodat;
144
- (window as any).Fodat = Fodat;
145
- (window as any).__bundledModules = __bundledModules;
146
- }
147
-
148
118
  if (typeof exports !== 'undefined') {
149
119
  exports.default = Fodat;
150
120
  exports.Fodat = Fodat;
151
121
  }
152
122
  return globalFunctModule;
153
123
 
154
- })(typeof global !== 'undefined' ? global :
155
- typeof window !== 'undefined' ? window :
156
- typeof self !== 'undefined' ? self :
157
- typeof globalThis !== 'undefined' ? globalThis :
158
- {});
124
+ })();
159
125
 
160
126
  type FodatElementTypeGF = typeof globalFunct.Fodat;
161
127
 
package/js/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const globalFunct = (function (global) {
1
+ const globalFunct = (function () {
2
2
  'use strict';
3
3
  class Fodat {
4
4
  static transform(formData) {
@@ -83,40 +83,18 @@ const globalFunct = (function (global) {
83
83
  }
84
84
  return path;
85
85
  }
86
- static exposeToGlobal() {
87
- if (typeof window !== "undefined") {
88
- window.Fodat = Fodat;
89
- }
90
- }
91
- }
92
- if (typeof window !== "undefined") {
93
- window.Fodat = Fodat;
94
86
  }
95
87
  const globalFunctModule = {
96
88
  default: Fodat,
97
89
  Fodat: Fodat,
98
90
  };
99
91
  const __bundledModules = globalFunctModule;
100
- if (typeof global !== 'undefined') {
101
- global.default = Fodat;
102
- global.Fodat = Fodat;
103
- global.__bundledModules = __bundledModules;
104
- }
105
- if (typeof window !== "undefined") {
106
- window.default = Fodat;
107
- window.Fodat = Fodat;
108
- window.__bundledModules = __bundledModules;
109
- }
110
92
  if (typeof exports !== 'undefined') {
111
93
  exports.default = Fodat;
112
94
  exports.Fodat = Fodat;
113
95
  }
114
96
  return globalFunctModule;
115
- })(typeof global !== 'undefined' ? global :
116
- typeof window !== 'undefined' ? window :
117
- typeof self !== 'undefined' ? self :
118
- typeof globalThis !== 'undefined' ? globalThis :
119
- {});
97
+ })();
120
98
  const FodatElementGF = globalFunct.Fodat;
121
99
  const defaultElementGF = globalFunct.default;
122
100
  export { defaultElementGF as default, FodatElementGF as Fodat, };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.0",
6
+ "version": "0.0.1-beta.0.2",
7
7
  "description": "Fodat est une bibliothèque JavaScript/TypeScript légère et puissante pour la transformation bidirectionnelle entre FormData et objets JSON. Conçue pour simplifier la manipulation des données de formulaires complexes avec support natif des fichiers et structures imbriquées",
8
8
  "main": "index.ts",
9
9
  "keywords": [],
package/web/fodat.js CHANGED
@@ -1,4 +1,4 @@
1
- const globalFunct = (function (global) {
1
+ const globalFunct = (function () {
2
2
  'use strict';
3
3
  class Fodat {
4
4
  static transform(formData) {
@@ -97,25 +97,11 @@ const globalFunct = (function (global) {
97
97
  Fodat: Fodat,
98
98
  };
99
99
  const __bundledModules = globalFunctModule;
100
- if (typeof global !== 'undefined') {
101
- global.default = Fodat;
102
- global.Fodat = Fodat;
103
- global.__bundledModules = __bundledModules;
104
- }
105
- if (typeof window !== "undefined") {
106
- window.default = Fodat;
107
- window.Fodat = Fodat;
108
- window.__bundledModules = __bundledModules;
109
- }
110
100
  if (typeof exports !== 'undefined') {
111
101
  exports.default = Fodat;
112
102
  exports.Fodat = Fodat;
113
103
  }
114
104
  return globalFunctModule;
115
- })(typeof global !== 'undefined' ? global :
116
- typeof window !== 'undefined' ? window :
117
- typeof self !== 'undefined' ? self :
118
- typeof globalThis !== 'undefined' ? globalThis :
119
- {});
105
+ })();
120
106
  const FodatElementGF = globalFunct.Fodat;
121
107
  const defaultElementGF = globalFunct.default;
package/web/fodat.min.js CHANGED
@@ -1 +1 @@
1
- let globalFunct=(e=>{class t{static transform(e){if(e instanceof FormData){var t,a,o={};for([t,a]of e.entries()){var n=this.parseKeyPath(t);this.setDeepValue(o,n,this.wrapValue(a))}return o}if("object"==typeof e&&!Array.isArray(e))return e}static toFormData(t,a=new FormData,o){return null!=t&&(!0===t?.__file&&t.file instanceof File?a.append(o,t.file):"object"!=typeof t||t instanceof File?o&&a.append(o,t):Array.isArray(t)?t.forEach((e,t)=>{this.toFormData(e,a,o?o+`[${t}]`:""+t)}):Object.keys(t).forEach(e=>{this.toFormData(t[e],a,o?o+"."+e:e)})),a}static wrapValue(e){return e instanceof File?e:"true"===(e=e.toString())||"false"!==e&&(isNaN(Number(e))?e:Number(e))}static setDeepValue(e,t,a){let o=e;for(let e=0;e<t.length-1;e++){var n=t[e],r=t[e+1];void 0===o[n]&&(o[n]="number"==typeof r?[]:{}),o=o[n]}e=t[t.length-1];o[e]=a}static parseKeyPath(e){var t,a=[];for(t of e.split(/\.|(\[\d+\])/).filter(Boolean)){var o=t.match(/\[(\d+)\]/);a.push(o?Number(o[1]):t)}return a}static exposeToGlobal(){"undefined"!=typeof window&&(window.Fodat=t)}}"undefined"!=typeof window&&(window.Fodat=t);var a={default:t,Fodat:t},o=a;return void 0!==e&&(e.default=t,e.Fodat=t,e.__bundledModules=o),"undefined"!=typeof window&&(window.default=t,window.Fodat=t,window.__bundledModules=o),"undefined"!=typeof exports&&(exports.default=t,exports.Fodat=t),a})("undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof globalThis?globalThis:{}),FodatElementGF=globalFunct.Fodat,defaultElementGF=globalFunct.default;
1
+ let globalFunct=(()=>{class t{static transform(t){if(t instanceof FormData){var e,a,r={};for([e,a]of t.entries()){var o=this.parseKeyPath(e);this.setDeepValue(r,o,this.wrapValue(a))}return r}if("object"==typeof t&&!Array.isArray(t))return t}static toFormData(e,a=new FormData,r){return null!=e&&(!0===e?.__file&&e.file instanceof File?a.append(r,e.file):"object"!=typeof e||e instanceof File?r&&a.append(r,e):Array.isArray(e)?e.forEach((t,e)=>{this.toFormData(t,a,r?r+`[${e}]`:""+e)}):Object.keys(e).forEach(t=>{this.toFormData(e[t],a,r?r+"."+t:t)})),a}static wrapValue(t){return t instanceof File?t:"true"===(t=t.toString())||"false"!==t&&(isNaN(Number(t))?t:Number(t))}static setDeepValue(t,e,a){let r=t;for(let t=0;t<e.length-1;t++){var o=e[t],n=e[t+1];void 0===r[o]&&(r[o]="number"==typeof n?[]:{}),r=r[o]}t=e[e.length-1];r[t]=a}static parseKeyPath(t){var e,a=[];for(e of t.split(/\.|(\[\d+\])/).filter(Boolean)){var r=e.match(/\[(\d+)\]/);a.push(r?Number(r[1]):e)}return a}static exposeToGlobal(){"undefined"!=typeof window&&(window.Fodat=t)}}"undefined"!=typeof window&&(window.Fodat=t);var e={default:t,Fodat:t};return"undefined"!=typeof exports&&(exports.default=t,exports.Fodat=t),e})(),FodatElementGF=globalFunct.Fodat,defaultElementGF=globalFunct.default;