@@ -167,7 +167,34 @@ module.exports = {
167167
168168 is_raw_json,
169169
170- // TODO: js doc and usage examples
170+ /**
171+ * Assign properties and comments from source to target object.
172+ *
173+ * @param {Object } target The target object to assign properties and comments
174+ * to.
175+ * @param {Object } source The source object to copy properties and comments
176+ * from.
177+ * @param {Array<string|number> } [keys] Optional array of keys to assign. If
178+ * not provided, all keys and non-property comments are assigned. If empty
179+ * array, only non-property comments are assigned.
180+ * @returns {Object } The target object with assigned properties and comments.
181+ *
182+ * @throws {TypeError } If target cannot be converted to object or keys is not
183+ * array or undefined.
184+ *
185+ * @example
186+ * const source = parse('{"a": 1 // comment a, "b": 2 // comment b}')
187+ * const target = {}
188+ *
189+ * // Copy all properties and comments
190+ * assign(target, source)
191+ *
192+ * // Copy only specific properties and their comments
193+ * assign(target, source, ['a'])
194+ *
195+ * // Copy only non-property comments
196+ * assign(target, source, [])
197+ */
171198 assign ( target , source , keys ) {
172199 if ( ! isObject ( target ) ) {
173200 throw new TypeError ( 'Cannot convert undefined or null to object' )
@@ -199,7 +226,43 @@ module.exports = {
199226 return assign ( target , source , keys )
200227 } ,
201228
202- // TODO: js doc and usage examples
229+ /**
230+ * Move comments from one location to another within objects.
231+ *
232+ * @param {Object } source The source object containing comments to move.
233+ * @param {Object } [target] The target object to move comments to. If not
234+ * provided, defaults to source (move within same object).
235+ * @param {Object } from The source comment location.
236+ * @param {string } from.kind The kind of comment prefix (e.g., 'before',
237+ * 'after', 'before-all', etc.).
238+ * @param {string } [from.key] The property key for property-specific comments.
239+ * Omit for non-property comments.
240+ * @param {Object } to The target comment location.
241+ * @param {string } to.kind The kind of comment prefix (e.g., 'before',
242+ * 'after', 'before-all', etc.).
243+ * @param {string } [to.key] The property key for property-specific comments.
244+ * Omit for non-property comments.
245+ * @param {boolean } [override=false] Whether to override existing comments at
246+ * the target location. If false, comments will be appended.
247+ *
248+ * @throws {TypeError } If source is not an object.
249+ *
250+ * @example
251+ * const obj = parse('{"a": 1 // comment on a}')
252+ *
253+ * // Move comment from after 'a' to before 'a'
254+ * moveComments(obj, obj,
255+ * { kind: 'after', key: 'a' },
256+ * { kind: 'before', key: 'a' }
257+ * )
258+ *
259+ * @example
260+ * // Move non-property comment
261+ * moveComments(obj, obj,
262+ * { kind: 'before-all' },
263+ * { kind: 'after-all' }
264+ * )
265+ */
203266 moveComments ( source , target , {
204267 kind : from_kind ,
205268 key : from_key
0 commit comments