You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

16 lines
340 B

import { isArray } from './_internals/isArray.js'
import { mapArray } from './map.js'
export function unwind(property, obj){
if (arguments.length === 1){
return _obj => unwind(property, _obj)
}
if (!isArray(obj[ property ])) return [ obj ]
return mapArray(x => ({
...obj,
[ property ] : x,
}),
obj[ property ])
}