Skip to content

Commit

Permalink
updated readme, removed unused code, fixed flatteRn typo
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPaska committed Feb 11, 2024
1 parent 53a801e commit 676bea4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Loading and parsing data from a common file formats like: CSV, JSON, TSV either
- [**pivot**](https://www.datapipe-js.com/docs/datapipe-js-array#pivot) (array, rowFields, columnField, dataField, aggFunction?, columnValues?) - Returns a reshaped (pivoted) array based on unique column values.
- [**transpose**](https://www.datapipe-js.com/docs/datapipe-js-array#transpose) (array) - Transpose rows to columns in an array
- [**sort**](https://www.datapipe-js.com/docs/datapipe-js-array#sort) ([fieldName(s)]) - Sort array of elements according to a field and direction specified. e.g. sort(array, 'name ASC', 'age DESC')
- [**flattenObject**](https://www.datapipe-js.com/docs/datapipe-js-array#flattenObject) (Object) - flattens complex nested object into simple object. e.g. flattenObject(obj)
- [**unflattenObject**](https://www.datapipe-js.com/docs/datapipe-js-array#unflattenObject) (Object) - unflattens simple object into complex nested object. e.g. unflattenObject(obj)

### Joining data arrays

Expand Down
5 changes: 0 additions & 5 deletions src/array/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ export function unflattenObject(data: any): any {
function setProperty(data: any, pName: string, value: any): any {
const pNames = pName.split('.')
let parent: any = data
/**
data['p1'] = {}
parent = data.p1
parent['p2'] = 123
*/

for (let i = 0; i < pNames.length - 1; i++) {
if (pNames[i] in parent) {
Expand Down
2 changes: 1 addition & 1 deletion src/data-pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export class DataPipe {
return unflattenObject(this.data);
}

flattern(): any {
flatten(): any {
return flatten(this.data);
}

Expand Down
2 changes: 1 addition & 1 deletion src/tests/array.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('Test array methods', () => {
expect(groups.length).toBe(3);
});

it('flattern', () => {
it('flatten', () => {
const testArray = [1, 4, [2, [5, 5, [9, 7]], 11], 0, [], []];
const flatten = pipeFuncs.flatten(testArray);
expect(flatten.length).toBe(9);
Expand Down

0 comments on commit 676bea4

Please sign in to comment.