Skip to content

Commit

Permalink
docs: update jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeltree committed Jun 25, 2024
1 parent cb6ed19 commit 17ff198
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/accessors/accessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function get<T extends object>(obj: T, path: LeafPath<T>) {
return _.get(obj, path) as LeafValue<T>;
}

/** Checks whether the path refers to a leaf value */
/** Check whether the path refers to a leaf value */
export function has<T extends object>(obj: T, path: LeafPath<T>) {
path = interpretPathHints(path);
const parent = _.get(obj, _.toPath(path).slice(0, -1));
Expand All @@ -30,7 +30,7 @@ export function has<T extends object>(obj: T, path: LeafPath<T>) {
}
}

/** in-place setter for a deeply nested value */
/** Set a leaf value by path in-place. */
export function set<T extends object>(
obj: T,
// eslint-disable-next-line @typescript-eslint/ban-types
Expand Down
3 changes: 2 additions & 1 deletion src/accessors/findDifference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { get } from './accessors.js';
import { Fragment } from '@typings';
import walkLeaves from './walkLeaves.js';

/** Find the differences between an object and it's modified clone (of same type)
/** Find the differences between an object and a modified subset of it
* @param original imagined as an immutable state object,
* whose properties can be thought of as the "original" ones.
* @param fragment a modified clone or subset of `original`,
* imagined as mutable and intended for making changes to.
* @yields a pair with a leaf path and the changed value inside `fragment`
*/
export default function* findDifference<T extends object>(
original: T,
Expand Down
2 changes: 1 addition & 1 deletion src/accessors/toTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';
import { set } from './accessors.js';
import { Primitive } from '@typings';

/** from path-value pairs to object */
/** Create a new object from a list of path-value entries */

export default function toTree(
leaves: readonly (readonly [string, Primitive])[],
Expand Down
1 change: 1 addition & 0 deletions src/accessors/walkLeaves.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from 'lodash';
import { Primitive, LeafPath } from '@typings';

/** Generate the leaf value entries inside the object */
export default function* walkLeaves<T extends object>(
target: T,
): Generator<readonly [LeafPath<T>, Primitive], undefined> {
Expand Down

0 comments on commit 17ff198

Please sign in to comment.