const removeElementAndReposition = (caretContainer: Node, pos: CaretPosition): CaretPosition => { const parentNode = pos.container(); const newPosition = Arr.indexOf(parentNode.childNodes, caretContainer).map(function (index) { return index < pos.offset() ? CaretPosition(parentNode, pos.offset() - 1) : pos; }).getOr(pos); remove(caretContainer); return newPosition; };
const add = (key: string): void => { // Remove duplicates first. Arr.indexOf(cache, key).each(remove); cache.unshift(key); // When max size is exceeded, the oldest colors will be removed if (cache.length > max) { cache.pop(); } LocalStorage.setItem(storageName, JSON.stringify(cache)); };
const addToHistory = function (url, fileType) { const items = history[fileType]; if (!/^https?/.test(url)) { return; } if (items) { if (Arr.indexOf(items, url) === -1) { history[fileType] = items.slice(0, HISTORY_LENGTH).concat(url); } } else { history[fileType] = [url]; } };
return TransformFind.closest(elem, function (e) { const nodeName = Node.name(e); return Arr.indexOf(headings, nodeName); }, function (e) {
return heading.bind((elm) => Arr.indexOf(headings, Node.name(elm))).getOr(0);