Skip to content

Commit eba3652

Browse files
committed
Documentation updated and code style refreshed
~ README.md - Examples updated ~ src/functions/add-fields.ts - A few intervals added ~ src/functions/find-items.ts - A few intervals added ~ src/functions/validate.ts - A few intervals added
1 parent c128e08 commit eba3652

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,14 @@ Normalize JSON:API Response (NJAR) solves the problem with the JSON:API response
9696
// "attributes": {
9797
// "title": "JSON:API paints my bikeshed!"
9898
// },
99-
// "relationships": {
100-
// "people": [
101-
// {
102-
// "type": "people",
103-
// "id": "9",
104-
// "attributes": {
105-
// "firstName": "Dan",
106-
// "lastName": "Gebhardt",
107-
// "twitter": "dgeb"
108-
// }
109-
// }
110-
// ]
99+
// "people": {
100+
// "type": "people",
101+
// "id": "9",
102+
// "attributes": {
103+
// "firstName": "Dan",
104+
// "lastName": "Gebhardt",
105+
// "twitter": "dgeb"
106+
// }
111107
// }
112108
// }
113109
// ]

src/functions/add-fields.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
12
/**
23
* Adding included items in the normalized result
34
*
45
* @param {Object} response - JSON:API styled response from the server.
56
* @throws {Error} An included item does not contain type field.
67
* @return {Object} result - Included items grouped by their type
78
*/
8-
99
export function addFields(response: any) {
1010
// Creating a variable for the result
1111
const result: any = {};
@@ -28,4 +28,4 @@ export function addFields(response: any) {
2828
}
2929
}
3030
return result;
31-
}
31+
}

src/functions/find-items.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/**
23
* Find all corresponding relationship items
34
*
@@ -23,4 +24,4 @@ export function findItems(response: any, temp: any) {
2324
(String(item.type) === String(temp.type))),
2425
);
2526
return result;
26-
}
27+
}

src/functions/validate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/**
23
* Validating data field from the server response
34
*
@@ -36,4 +37,4 @@ export function validate(response: any) {
3637
throw new Error('[Normalize] [JSON:API Syntax Error] Not all data items are the same type!');
3738
}
3839
}
39-
}
40+
}

0 commit comments

Comments
 (0)