carbon-react
Version:
A library of reusable React components for easily building user interfaces.
2 lines (1 loc) • 504 B
JavaScript
import"react";function t(t,e,r=-1){const n=t.slice(-1),o=t.split("").every((t=>t===n));let s=function(t,e){return e.findIndex((e=>{var r;return null===(r=e.props.text)||void 0===r?void 0:r.toLowerCase().startsWith(t.toLowerCase())}))}(t,e);const i=function(t,e){return t.reduce(((t,r,n)=>(r.props.text&&r.props.text.toLowerCase().startsWith(e.toLowerCase())&&t.push(n),t)),[])}(e,n);return o&&i.length>1&&(s=function(t,e){return e===t[t.length-1]?t[0]:t[t.indexOf(e)+1]}(i,r)),e[s]}export{t as default};