Skip to content

Commit 0d10ba3

Browse files
committed
docs(kitsu-core): add internal documentation for new private functions
1 parent 920ece3 commit 0d10ba3

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

  • packages/kitsu-core/src/serialise

packages/kitsu-core/src/serialise/index.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { error } from '../error'
33
/**
44
* Checks if data is valid for serialisation
55
*
6-
* @param {Object} obj The data
6+
* @param {Boolean} isArray If root element of the payload was an Array or Object
7+
* @param {string} type Resource type
8+
* @param {Object} payload The data
79
* @param {string} method Request type - `PATCH` or `POST`
810
* @private
911
*/
@@ -96,6 +98,18 @@ function hasID (node) {
9698
return Object.prototype.hasOwnProperty.call(node, 'id')
9799
}
98100

101+
/**
102+
* Handles the Bulk Extension support. See `serialise` for examples.
103+
*
104+
* @param {string} type Resource type
105+
* @param {Array} payload The data
106+
* @param {string} method Request type (PATCH, POST, DELETE)
107+
* @param {Object} options Optional configuration for camelCase and pluralisation handling
108+
* @param {Function} options.camelCaseTypes Convert library-entries and library_entries to libraryEntries (default no conversion). To use parameter, import camel from kitsu-core
109+
* @param {Function} options.pluralTypes Pluralise types (default no pluralisation). To use parameter, import pluralize (or another pluralisation npm package)
110+
* @returns {Object} The serialised data
111+
* @private
112+
*/
99113
function serialiseRootArray (type, payload, method, options) {
100114
isValid(true, type, payload, method)
101115
const data = []
@@ -105,6 +119,18 @@ function serialiseRootArray (type, payload, method, options) {
105119
return { data }
106120
}
107121

122+
/**
123+
* Serialises the root data object. See `serialise` for examples.
124+
*
125+
* @param {string} type Resource type
126+
* @param {Array} payload The data
127+
* @param {string} method Request type (PATCH, POST, DELETE)
128+
* @param {Object} options Optional configuration for camelCase and pluralisation handling
129+
* @param {Function} options.camelCaseTypes Convert library-entries and library_entries to libraryEntries (default no conversion). To use parameter, import camel from kitsu-core
130+
* @param {Function} options.pluralTypes Pluralise types (default no pluralisation). To use parameter, import pluralize (or another pluralisation npm package)
131+
* @returns {Object} The serialised data
132+
* @private
133+
*/
108134
function serialiseRootObject (type, payload, method, options) {
109135
isValid(false, type, payload, method)
110136
let data = { type }
@@ -132,7 +158,7 @@ function serialiseRootObject (type, payload, method, options) {
132158
/**
133159
* Serialises an object into a JSON-API structure
134160
*
135-
* @param {string} model Request model
161+
* @param {string} type Resource type
136162
* @param {Object|Array} data The data
137163
* @param {string} method Request type (PATCH, POST, DELETE)
138164
* @param {Object} options Optional configuration for camelCase and pluralisation handling

0 commit comments

Comments
 (0)