Skip to content

Commit 666f535

Browse files
committed
WIP
1 parent fe7e663 commit 666f535

File tree

5 files changed

+61
-5
lines changed

5 files changed

+61
-5
lines changed

.build/clean.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const pathsToClean = [
77
"./dist"
88
];
99

10-
for(let i=0; i< pathsToClean.length; i++) {
10+
for (let i = 0; i < pathsToClean.length; i++) {
1111
let matches = glob.sync(pathsToClean[i], []);
12-
for(let j=0; j < matches.length; j++) {
12+
for (let j = 0; j < matches.length; j++) {
1313
rimraf.sync(matches[j]);
1414
}
1515
}

.build/minify.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const _fs = require('fs');
2+
const _path = require('path');
3+
const _glob = require('glob');
4+
const _uglifyJS = require("uglify-js");
5+
6+
7+
function writeMinifiedFileSync(path, content, encding) {
8+
const file = _path.parse(path);
9+
const minifiedFilePath = _path.join(file.dir, `${file.name}.min${file.ext}`);
10+
_fs.writeFileSync(minifiedFilePath, content, encding);
11+
}
12+
13+
14+
_glob
15+
.sync('./dist/js/**/*.js', [])
16+
.forEach(f => {
17+
writeMinifiedFileSync(f, _uglifyJS.minify(_fs.readFileSync(f, 'utf8'), {}).code, 'utf8');
18+
console.log(`Minified "${f}"`);
19+
});

package-lock.json

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@
1010
"@types/jsdom": "16.1.0",
1111
"@types/mocha": "7.0.1",
1212
"chai": "4.2.0",
13+
"glob": "7.1.6",
1314
"jsdom": "16.2.0",
1415
"mocha": "7.0.1",
1516
"nyc": "15.0.0",
1617
"rimraf": "3.0.2",
1718
"source-map-support": "0.5.16",
1819
"ts-node": "8.6.2",
19-
"typescript": "3.8.2"
20+
"typescript": "3.8.2",
21+
"uglify-js": "3.8.0"
2022
},
2123
"scripts": {
2224
"clean": "node ./.build/clean.js",
23-
"build": "tsc",
25+
"prebuild": "npm run clean",
26+
"build": "tsc && node ./.build/minify.js",
2427
"test": "nyc mocha",
2528
"dev": "tsc -w"
2629
},
@@ -38,5 +41,9 @@
3841
"bugs": {
3942
"url": "https://github.com/validide/javascript-browser-utilities/issues"
4043
},
41-
"homepage": "https://github.com/validide/javascript-browser-utilities#readme"
44+
"homepage": "https://github.com/validide/javascript-browser-utilities#readme",
45+
"files": [
46+
"dist",
47+
"src"
48+
]
4249
}

src/form/appendDataToForm.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ function appendData(ownerDocument: Document, form: HTMLFormElement, data: any, p
2020
}
2121
}
2222

23+
/**
24+
* Append an object to a form as `input`([[HTMLInputElement]]) elements
25+
* @param data The information to append to the the ´form´
26+
* @param form The form ([[HTMLFormElement]]) element to elements to
27+
* @throws {Error} if the ´form´ does not have an 'ownerDocument'
28+
*/
2329
function appendDataToForm(data: Object | null, form: HTMLFormElement): void {
2430
if (!data)
2531
return;

0 commit comments

Comments
 (0)