-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(csv-demo-webpack): split usages by packages
- Loading branch information
Showing
25 changed files
with
410 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/dist/main.js | ||
/dist/*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Package `csv` webpack demonstration</title> | ||
<script src="./csv.js"></script> | ||
</head> | ||
<body> | ||
<button id="run" type="button">run</button> | ||
<pre><code id="output">...waiting...</code></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Package `csv` webpack demonstration</title> | ||
<script src="./csv_sync.js"></script> | ||
</head> | ||
<body> | ||
<button id="run" type="button">run</button> | ||
<pre><code id="output">...waiting...</code></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Package `csv-generate` webpack demonstration</title> | ||
<script src="./generate.js"></script> | ||
</head> | ||
<body> | ||
<button id="run" type="button">run</button> | ||
<pre><code id="output">...waiting...</code></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Package `csv-generate` webpack demonstration</title> | ||
<script src="./generate_sync.js"></script> | ||
</head> | ||
<body> | ||
<button id="run" type="button">run</button> | ||
<pre><code id="output">...waiting...</code></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Package `csv-parse` webpack demonstration</title> | ||
<script src="./parse.js"></script> | ||
</head> | ||
<body> | ||
<button id="run" type="button">run</button> | ||
<pre><code id="output">...waiting...</code></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Package `csv-parse` webpack demonstration</title> | ||
<script src="./parse_sync.js"></script> | ||
</head> | ||
<body> | ||
<button id="run" type="button">run</button> | ||
<pre><code id="output">...waiting...</code></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Package `csv-stringify` webpack demonstration</title> | ||
<script src="./stringify.js"></script> | ||
</head> | ||
<body> | ||
<button id="run" type="button">run</button> | ||
<pre><code id="output">...waiting...</code></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Package `csv-stringify` webpack demonstration</title> | ||
<script src="./stringify_sync.js"></script> | ||
</head> | ||
<body> | ||
<button id="run" type="button">run</button> | ||
<pre><code id="output">...waiting...</code></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Package `stream-transform` webpack demonstration</title> | ||
<script src="./transform.js"></script> | ||
</head> | ||
<body> | ||
<button id="run" type="button">run</button> | ||
<pre><code id="output">...waiting...</code></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Package `stream-transform` webpack demonstration</title> | ||
<script src="./transform_sync.js"></script> | ||
</head> | ||
<body> | ||
<button id="run" type="button">run</button> | ||
<pre><code id="output">...waiting...</code></pre> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
import * as csv from 'csv/browser/esm/index.js'; | ||
|
||
window.onload = () => { | ||
const runEl = document.getElementById('run'); | ||
const outputEl = document.getElementById('output'); | ||
runEl.onclick = (e) => { | ||
// Run the pipeline | ||
csv | ||
// Generate 20 records | ||
.generate({ | ||
delimiter: '|', | ||
length: 10 | ||
}) | ||
// Transform CSV data into records | ||
.pipe(csv.parse({ | ||
delimiter: '|' | ||
})) | ||
// Transform each value into uppercase | ||
.pipe(csv.transform( (record) => { | ||
record.push(record.shift()); | ||
return record; | ||
})) | ||
// Convert objects into a stream | ||
.pipe(csv.stringify({ | ||
quoted: true | ||
})) | ||
// Print the CSV stream to stdout | ||
.on('readable', function () { | ||
let chunck; while(chunck = this.read()){ | ||
outputEl.innerHTML = outputEl.innerHTML + chunck.toString() | ||
} | ||
}) | ||
.on('error', function (err) { | ||
outputEl.innerHTML = 'Error: ' + err.message; | ||
}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
import * as csv from 'csv/browser/esm/sync.js'; | ||
|
||
window.onload = () => { | ||
const runEl = document.getElementById('run'); | ||
const outputEl = document.getElementById('output'); | ||
runEl.onclick = (e) => { | ||
try{ | ||
// Run the pipeline | ||
const input = csv.generate({ | ||
delimiter: '|', | ||
length: 10 | ||
}); | ||
const rawRecords = csv.parse(input, { | ||
delimiter: '|' | ||
}); | ||
const refinedRecords = csv.transform(rawRecords, (record) => { | ||
record.push(record.shift()); | ||
return record; | ||
}); | ||
const output = csv.stringify(refinedRecords, { | ||
quoted: true | ||
}); | ||
outputEl.innerHTML = output; | ||
}catch(err){ | ||
outputEl.innerHTML = 'Error: ' + err.message; | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
import {generate} from 'csv-generate/browser/esm/index.js'; | ||
|
||
window.onload = () => { | ||
const runEl = document.getElementById('run'); | ||
const outputEl = document.getElementById('output'); | ||
runEl.onclick = (e) => { | ||
generate({ | ||
objectMode: true, | ||
length: 2 | ||
}, (err, records) => { | ||
outputEl.innerHTML = JSON.stringify(records, null, 2); | ||
}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
import {generate} from 'csv-generate/browser/esm/sync.js'; | ||
|
||
window.onload = () => { | ||
const runEl = document.getElementById('run'); | ||
const outputEl = document.getElementById('output'); | ||
runEl.onclick = (e) => { | ||
const records = generate({ | ||
objectMode: true, | ||
length: 2 | ||
}); | ||
outputEl.innerHTML = JSON.stringify(records, null, 2); | ||
}; | ||
}; |
Oops, something went wrong.