Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ppaska authored Dec 8, 2019
1 parent 2fb7966 commit c8da7a6
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,55 @@ npm install datapipe-js
```

## A quick example

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"}
]
];

const summaryForUS = dataPipe(data)
.groupBy(i => i.country)
.select(g =>
r = {}
r.country = dataPipe(g).first().country
r.names = dataPipe(g).map(r => r.name).join(", ")
r.count = dataPipe(g).count()
r
r = {
country: dataPipe(g).first().country,
names: dataPipe(g).map(r => r.name).join(", "),
count: dataPipe(g).count()
};
return r
)
.where(r => r.country != "US")
.toArray();

console.log(summaryForUS);
```

JSPython
```py

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"}
]

summaryForUS = dataPipe(data)
.groupBy(i => i.country)
.select(g =>
r = {
country: dataPipe(g).first().country,
names: dataPipe(g).map(r => r.name).join(", "),
count: dataPipe(g).count()
}
return r
)
.where(r => r.country != "US")
.toArray()

print(summaryForUS)

```


## Functionality

### Data Loading
Expand Down

0 comments on commit c8da7a6

Please sign in to comment.