import { createArrayFromView } from '@h5web/shared' ; import ndarray from 'ndarray' ; export function flipLastDimension ( value , dims ) { const baseArray = ndarray ( value , dims ) ; const steps = dims . map ( ( _ , index ) => ( index === dims . length - 1 ? - 1 : 1 ) ) ; const flippedView = baseArray . step ( ... steps ) ; return createArrayFromView ( flippedView ) . data ; }