@daren/utils
Advanced tools
Comparing version 1.8.3 to 1.8.4
@@ -21,3 +21,4 @@ "use strict"; | ||
return function (match) { | ||
var startIndex = match.index; | ||
var _match$index; | ||
var startIndex = (_match$index = match.index) != null ? _match$index : 0; | ||
var tagRange = reversedHtmlTagRangeList.find(function (_ref) { | ||
@@ -37,3 +38,4 @@ var rangeStart = _ref[0]; | ||
return [].concat(htmlTagMatchList).map(function (htmlTagMatch) { | ||
var startIndex = htmlTagMatch.index; | ||
var _htmlTagMatch$index; | ||
var startIndex = (_htmlTagMatch$index = htmlTagMatch.index) != null ? _htmlTagMatch$index : 0; | ||
var tag = htmlTagMatch[0]; | ||
@@ -75,5 +77,6 @@ var tagLength = tag.length; | ||
for (var _iterator = _createForOfIteratorHelperLoose(convertibleMatchList), _step; !(_step = _iterator()).done;) { | ||
var _match$index2; | ||
var match = _step.value; | ||
var _isHtmlTag = checkIsHtmlTag(match); | ||
if (_isHtmlTag) { | ||
var htmlTag = checkIsHtmlTag(match); | ||
if (htmlTag) { | ||
if (ELEMENTS_TO_SKIP.includes(match[0].toUpperCase())) { | ||
@@ -89,5 +92,7 @@ if (skipping) { | ||
var matchedWord = match[0]; | ||
var startIndex = match.index; | ||
var startIndex = (_match$index2 = match.index) != null ? _match$index2 : 0; | ||
var endIndex = startIndex + getFixationLength(matchedWord); | ||
if (!skipping) { | ||
if (skipping) { | ||
result += textToBionify.slice(lastMatchedIndex, endIndex); | ||
} else { | ||
var plainText = textToBionify.slice(lastMatchedIndex, startIndex); | ||
@@ -98,4 +103,2 @@ result += plainText; | ||
} | ||
} else { | ||
result += textToBionify.slice(lastMatchedIndex, endIndex); | ||
} | ||
@@ -102,0 +105,0 @@ lastMatchedIndex = endIndex; |
@@ -10,3 +10,3 @@ "use strict"; | ||
setState = _useState[1]; | ||
var value = propValue !== undefined ? propValue : stateValue; | ||
var value = propValue ? stateValue : undefined; | ||
return [value, function (newValue) { | ||
@@ -13,0 +13,0 @@ setState(newValue); |
@@ -14,3 +14,4 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
return match => { | ||
var startIndex = match.index; | ||
var _match$index; | ||
var startIndex = (_match$index = match.index) != null ? _match$index : 0; | ||
var tagRange = reversedHtmlTagRangeList.find(_ref => { | ||
@@ -30,3 +31,4 @@ var [rangeStart] = _ref; | ||
return [...htmlTagMatchList].map(htmlTagMatch => { | ||
var startIndex = htmlTagMatch.index; | ||
var _htmlTagMatch$index; | ||
var startIndex = (_htmlTagMatch$index = htmlTagMatch.index) != null ? _htmlTagMatch$index : 0; | ||
var [tag] = htmlTagMatch; | ||
@@ -71,4 +73,5 @@ var { | ||
for (var match of convertibleMatchList) { | ||
var _isHtmlTag = checkIsHtmlTag(match); | ||
if (_isHtmlTag) { | ||
var _match$index2; | ||
var htmlTag = checkIsHtmlTag(match); | ||
if (htmlTag) { | ||
if (ELEMENTS_TO_SKIP.includes(match[0].toUpperCase())) { | ||
@@ -84,5 +87,7 @@ if (skipping) { | ||
var [matchedWord] = match; | ||
var startIndex = match.index; | ||
var startIndex = (_match$index2 = match.index) != null ? _match$index2 : 0; | ||
var endIndex = startIndex + getFixationLength(matchedWord); | ||
if (!skipping) { | ||
if (skipping) { | ||
result += textToBionify.slice(lastMatchedIndex, endIndex); | ||
} else { | ||
var plainText = textToBionify.slice(lastMatchedIndex, startIndex); | ||
@@ -93,4 +98,2 @@ result += plainText; | ||
} | ||
} else { | ||
result += textToBionify.slice(lastMatchedIndex, endIndex); | ||
} | ||
@@ -97,0 +100,0 @@ lastMatchedIndex = endIndex; |
import { useState } from 'react'; | ||
function useControllableState(propValue, initialValue, changeHandler) { | ||
var [stateValue, setState] = useState(initialValue); | ||
var value = propValue !== undefined ? propValue : stateValue; | ||
var value = propValue ? stateValue : undefined; | ||
return [value, newValue => { | ||
@@ -6,0 +6,0 @@ setState(newValue); |
import { Dispatch, SetStateAction } from 'react'; | ||
declare function useControllableState<T>(propValue: T | undefined, initialValue: T | (() => T), changeHandler?: Dispatch<SetStateAction<T | undefined>>): [T, (value: T) => void]; | ||
declare function useControllableState<T>(propValue: T | undefined, initialValue: T | (() => T), changeHandler?: Dispatch<SetStateAction<T | undefined>>): [T | undefined, (value: T) => void]; | ||
export { useControllableState }; | ||
//# sourceMappingURL=hooks.d.ts.map |
{ | ||
"name": "@daren/utils", | ||
"version": "1.8.3", | ||
"version": "1.8.4", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1003
138541
62