Skip to content

Commit 34acd70

Browse files
committed
Handle compactArrays option.
1 parent f085fbe commit 34acd70

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/compact.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,10 @@ api.compact = ({
385385
nestResult, itemActiveProperty, compactedItem,
386386
{propertyIsArray: (!options.compactArrays || container.includes('@set'))});
387387
} else {
388-
// wrap using @graph alias, remove array if only one item
389-
if(_isArray(compactedItem) && compactedItem.length === 1) {
388+
// wrap using @graph alias, remove array if only one item and
389+
// compactArrays not set
390+
if(_isArray(compactedItem) && compactedItem.length === 1 &&
391+
options.compactArrays) {
390392
compactedItem = compactedItem[0];
391393
}
392394
compactedItem = {

0 commit comments

Comments
 (0)