Skip to content

Commit

Permalink
a mayor structure refactoring and PIVOT array implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ppaska committed Feb 16, 2020
1 parent 21544bb commit b3938ff
Show file tree
Hide file tree
Showing 30 changed files with 506 additions and 369 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ npm install datapipe-js
JavaScript / TypeScript
```js
const data = [
{ name: "John", country: "US"}, { name: "Joe", country: "US"}, { name: "Bill", country: "US"}, { name: "Adam", country: "UK"},
{ name: "Scott", country: "UK"}, { name: "Diana",country: "UK"}, { name: "Marry",country: "FR"}, { name: "Luc",country: "FR"}
{ name: "John", country: "US"}, { name: "Joe", country: "US"}, { name: "Bill", country: "US"},
{ name: "Adam", country: "UK"}, { name: "Scott", country: "UK"}, { name: "Diana",country: "UK"},
{ name: "Marry",country: "FR"}, { name: "Luc",country: "FR"}
];

const summaryForUS = dataPipe(data)
Expand Down
18 changes: 9 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ <h4>Data Pipe testing page. Do not expect anything here! </h4>
<script>

let csv = `
F1,F2,F3,F4,F5
11,12.5,1234.22,tt,"1 2,t3 4 5"
21,22.2,1321.32,yy,"5 4,t3 2 1"
`;
Product,Year,Sale
P1,2017,11
P1,2017,20
P1,2018,12
P2,2017,21
P2,2018,21
P3,2017,31`;

function onButtonClick() {
const csv = ["", "", "F1\tF2\tF3", `1\t1,000.32\t"Test, comma"`, "\t\t"].join('\n')
const arr = dataPipe.dataPipe()
.fromCsv(csv, { separator: '\t' })
.toArray();
console.log(arr);
const res = dp.pivot(dp.parseCsv(csv), "Product", "Year", "Sale")
console.log(res);
}

onButtonClick();
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datapipe-js",
"version": "0.0.8",
"version": "0.1.0",
"description": "dataPipe is a JavaScript library for data manipulations, data transformations and data analytics inspired by LINQ (C#) and Pandas - (Python)",
"main": "dist/data-pipe.min.js",
"module": "dist/data-pipe.esm.js",
Expand Down Expand Up @@ -32,7 +32,7 @@
"keywords": [
"data",
"data-analysis",
"linq",
"LINQ",
"pandas",
"data-management",
"data-science",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {

input: 'src/index.ts',
output: {
name: 'dataPipe',
name: 'dp',
file: 'dist/data-pipe.min.js',
format: 'umd',
sourcemap: true,
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const input = 'src/index.ts';
export default [{
input,
output: [
{ file: pkg.main, name: 'dataPipe', format: 'umd', sourcemap: true, compact: true },
{ file: pkg.main, name: 'dp', format: 'umd', sourcemap: true, compact: true },
],
treeshake: true,
plugins: [
Expand Down
13 changes: 13 additions & 0 deletions src/_internals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Selector } from "./types";

export function fieldSelector(input: string | string[] | Selector<any, string>): Selector<any, string> {
if (typeof input === "function") {
return input;
} else if (typeof input === "string") {
return (item) => item[input];
} else if (Array.isArray(input)) {
return (item) => input.map(r => item[r]).join('|');
} else {
throw Error(`Unknown input. Can't create a fieldSelector`)
}
}
201 changes: 0 additions & 201 deletions src/array.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/array/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './joins'
export * from './stats'
export * from './transform'
Loading

0 comments on commit b3938ff

Please sign in to comment.