Skip to content

Commit

Permalink
inline destructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Mar 7, 2023
1 parent 96a659c commit f32b77e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/transforms/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {ascendingDefined, descendingDefined} from "../defined.js";
import {arrayify, isDomainSort, isOptions, maybeValue, valueof} from "../options.js";

/** @jsdoc transform */
export function basic(options = {}, transform) {
let {filter: f1, sort: s1, reverse: r1, transform: t1, initializer: i1, ...remainingOptions} = options;
export function basic({filter: f1, sort: s1, reverse: r1, transform: t1, initializer: i1, ...options} = {}, transform) {
// If both t1 and t2 are defined, returns a composite transform that first
// applies t1 and then applies t2.
if (t1 === undefined) {
Expand All @@ -15,15 +14,14 @@ export function basic(options = {}, transform) {
}
if (transform != null && i1 != null) throw new Error("transforms cannot be applied after initializers");
return {
...remainingOptions,
...options,
...((s1 === null || isDomainSort(s1)) && {sort: s1}),
transform: composeTransform(t1, transform)
};
}

/** @jsdoc initializer */
export function initializer(options = {}, initializer) {
let {filter: f1, sort: s1, reverse: r1, initializer: i1, ...remainingOptions} = options;
export function initializer({filter: f1, sort: s1, reverse: r1, initializer: i1, ...options} = {}, initializer) {
// If both i1 and i2 are defined, returns a composite initializer that first
// applies i1 and then applies i2.
if (i1 === undefined) {
Expand All @@ -33,7 +31,7 @@ export function initializer(options = {}, initializer) {
if (r1) i1 = composeInitializer(i1, reverseTransform);
}
return {
...remainingOptions,
...options,
...((s1 === null || isDomainSort(s1)) && {sort: s1}),
initializer: composeInitializer(i1, initializer)
};
Expand Down

0 comments on commit f32b77e

Please sign in to comment.