@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 +1 -1
- package/index.ts +2 -36
- package/js/index.js +2 -24
- package/package.json +1 -1
- package/web/fodat.js +2 -16
- package/web/fodat.min.js +1 -1
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
|
-
|
|
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
|
-
})(
|
|
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 (
|
|
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
|
-
})(
|
|
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 (
|
|
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
|
-
})(
|
|
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=(
|
|
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;
|