nl_tokens: / * Given state an item and an offset : return the item that is offset away from the currentItem in the list .
pl_tokens: function getOffsetItem ( state , currentItem , offset ) { const streamKey = getCurrentStream ( state ) ; if ( ! streamKey || ! state . reader . streams [ streamKey ] ) { return null ; } const stream = state . reader . streams [ streamKey ] ; let index = findIndex ( <mask> . items , item => keysAreEqual ( item , currentItem ) ) ; // If we didn't find a match, check x-posts too if ( index < 0 ) { index = findIndex ( stream . items , item => keysAreEqual ( item . xPostMetadata , currentItem ) ) ; } if ( index < 0 ) { return null ; } const newIndex = index + offset ; if ( newIndex < 0 || newIndex >= stream . items . length ) { return null ; } const offsetItem = stream . items [ newIndex ] ; // If the item is an x-post, return the original post details if ( offsetItem && offsetItem . xPostMetadata ) { return offsetItem . xPostMetadata ; } return offsetItem ; }