@designbycosmic/cosmic-unwidower
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -8,2 +8,8 @@ "use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/** | ||
@@ -20,26 +26,39 @@ * | ||
* | ||
* @param {number} [minWords=4] the minimum number of words before apply the algo | ||
* * params for three word widow removal, all words must be at most this long | ||
* @param {number} [maxLastWordLength=9] | ||
* @param {number} [maxPenultWordLength=4] | ||
* @param {number} [maxAntepenultWordLength=5] | ||
* * params for two word widow removal, if words are too long for three word | ||
* * widow removal, all words must be at most this long | ||
* @param {number} [maxLastWordLengthTwo=13] | ||
* @param {number} [maxPenultWordLengthTwo=11] | ||
* @param {object} [config={ | ||
minWords: 4, | ||
maxLastWordLength: 9, | ||
maxPenultWordLength: 4, | ||
maxAntepenultWordLength: 5, | ||
maxLastWordLengthTwo: 13, | ||
maxPenultWordLengthTwo: 11, | ||
}] the config object | ||
* @returns | ||
*/ | ||
var unWidowerClient = function unWidowerClient() { | ||
var minWords = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4; | ||
var maxLastWordLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 9; | ||
var maxPenultWordLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 4; | ||
var maxAntepenultWordLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 5; | ||
var maxLastWordLengthTwo = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 13; | ||
var maxPenultWordLengthTwo = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 11; | ||
var unWidowerClient = function unWidowerClient(config) { | ||
// make sure there is a window in case this was included SSR | ||
// otherwise show a warning | ||
if (typeof window !== "undefined") { | ||
// document is grabbed from client | ||
var defaultConfig = { | ||
minWords: 4, | ||
maxLastWordLength: 9, | ||
// defaults for three-word widow breaker | ||
maxPenultWordLength: 4, | ||
// defaults for three-word widow breaker | ||
maxAntepenultWordLength: 5, | ||
// defaults for two-word widow-breaker | ||
maxLastWordLengthTwo: 13, | ||
// defaults for two-word widow-breaker | ||
maxPenultWordLengthTwo: 11 | ||
}; // merge passed config with default | ||
var _defaultConfig$config = _objectSpread({}, defaultConfig, {}, config), | ||
minWords = _defaultConfig$config.minWords, | ||
maxLastWordLength = _defaultConfig$config.maxLastWordLength, | ||
maxPenultWordLength = _defaultConfig$config.maxPenultWordLength, | ||
maxAntepenultWordLength = _defaultConfig$config.maxAntepenultWordLength, | ||
maxLastWordLengthTwo = _defaultConfig$config.maxLastWordLengthTwo, | ||
maxPenultWordLengthTwo = _defaultConfig$config.maxPenultWordLengthTwo; // document is grabbed from client | ||
// eslint-disable-next-line no-undef | ||
document // loop through elements containing text | ||
@@ -81,2 +100,2 @@ .querySelectorAll("h1,h2,h3,h4,h5,p,blockquote,li,ol,span").forEach(function (el) { | ||
exports["default"] = _default; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91bldpZG93ZXJDbGllbnQuanMiXSwibmFtZXMiOlsidW5XaWRvd2VyQ2xpZW50IiwibWluV29yZHMiLCJtYXhMYXN0V29yZExlbmd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9uIGEgbGluZSBhcmUgc2hvcnRcbiAgICAgICAgICAgICAgLy8gZW5vdWdoIHRvIGxvb2sgbGlrZSBhIHdpZG93XG4gICAgICAgICAgICAgIGxhc3R3b3JkLmxlbmd0aCA8IG1heExhc3RXb3JkTGVuZ3RoICYmXG4gICAgICAgICAgICAgIHBlbnVsdHdvcmQubGVuZ3RoIDwgbWF4UGVudWx0V29yZExlbmd0aCAmJlxuICAgICAgICAgICAgICBhbnRlcGVudWx0d29yZC5sZW5ndGggPCBtYXhBbnRlcGVudWx0V29yZExlbmd0aFxuICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgIGVsZW1lbnQuaW5uZXJIVE1MID0gZWwuaW5uZXJIVE1MLnJlcGxhY2UoXG4gICAgICAgICAgICAgICAgLyAoPz1bXiBdKiQpL2ksXG4gICAgICAgICAgICAgICAgXCJcXHUwMGEwXCJcbiAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgICAgZWxlbWVudC5pbm5lckhUTUwgPSBlbC5pbm5lckhUTUwucmVwbGFjZShcbiAgICAgICAgICAgICAgICAvICg/PVteIF0qJCkvaSxcbiAgICAgICAgICAgICAgICBcIlxcdTAwYTBcIlxuICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChcbiAgICAgICAgICAgICAgLy8gb3RoZXJ3aXNlLCBqdXN0IGNyZWF0ZSBhbiBuYnNwIGJldHdlZW4gdGhlIGxhc3QgdHdvIHdvcmRzLFxuICAgICAgICAgICAgICAvLyBhc3N1bWluZyB0aGF0IHRoZXkncmUgYWxzbyBzaG9ydCBlbm91Z2hcbiAgICAgICAgICAgICAgbGFzdHdvcmQubGVuZ3RoIDwgbWF4TGFzdFdvcmRMZW5ndGhUd28gJiZcbiAgICAgICAgICAgICAgcGVudWx0d29yZC5sZW5ndGggPCBtYXhQZW51bHRXb3JkTGVuZ3RoVHdvXG4gICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgLy8gcmVwbGFjZSBsYXN0IGJyZWFraW5nIHNwYWNlIHdpdGggYSBuYnNwXG4gICAgICAgICAgICAgIGVsZW1lbnQuaW5uZXJIVE1MID0gZWwuaW5uZXJIVE1MLnJlcGxhY2UoXG4gICAgICAgICAgICAgICAgLyAoPz1bXiBdKiQpL2ksXG4gICAgICAgICAgICAgICAgXCJcXHUwMGEwXCJcbiAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0pO1xuICB9IGVsc2Uge1xuICAgIC8vIFdhcm4gZGV2ZWxvcGVycyBpZiB0aGV5J3JlIHVzaW5nIHRoaXMgaW4gdGhlIHdyb25nIGNvbnRleHQuXG4gICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIG5vLWNvbnNvbGVcbiAgICBjb25zb2xlLndhcm4oXG4gICAgICBcInVuV2lkb3dlckNsaWVudCBpcyBvbmx5IGludGVuZGVkIGZvciBjbGllbnQtc2lkZSB1c2UuIENoZWNrIHRoZSBSRUFETUUgZm9yIG1vcmUgaW5mby4gSWYgdGhpcyBzY3JpcHQgaXMgcnVuIGFnYWluIGNsaWVudC1zaWRlLCB5b3UgY2FuIGlnbm9yZSB0aGlzIG1lc3NhZ2UuXCJcbiAgICApO1xuICB9XG59O1xuXG5leHBvcnQgZGVmYXVsdCB1bldpZG93ZXJDbGllbnQ7XG4iXX0= | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91bldpZG93ZXJDbGllbnQuanMiXSwibmFtZXMiOlsidW5XaWRvd2VyQ2xpZW50IiwiY29uZmlnIiwid2luZG93IiwiZGVmYXVsdENvbmZpZyIsIm1pbldvcmRzIiwibWF4TGFzdFdvcmRMZW5ndGgiLCJtYXhQZW51bHRXb3JkTGVuZ3RoIiwibWF4QW50ZXBlbnVsdFdvcmRMZW5ndGgiLCJtYXhMYXN0V29yZExlbmd0aFR3byIsIm1heFB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gICAgICAgIGlmIChlbGVtZW50LmlubmVySFRNTC5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgY29uc3QgY29weSA9IGVsZW1lbnQuaW5uZXJIVE1MLnNwbGl0KFwiIFwiKTtcbiAgICAgICAgICAvLyBpZiBjb3B5IGlzIGF0IGxlYXN0IG1pbmltdW0gbnVtYmVyIG9mIHdvcmRzXG4gICAgICAgICAgaWYgKGNvcHkubGVuZ3RoID49IG1pbldvcmRzKSB7XG4gICAgICAgICAgICBjb25zdCBsYXN0d29yZCA9IGNvcHlbY29weS5sZW5ndGggLSAxXTtcbiAgICAgICAgICAgIGNvbnN0IHBlbnVsdHdvcmQgPSBjb3B5W2NvcHkubGVuZ3RoIC0gMl07XG4gICAgICAgICAgICBjb25zdCBhbnRlcGVudWx0d29yZCA9IGNvcHlbY29weS5sZW5ndGggLSAzXTtcbiAgICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICAgLy8gcmVwbGFjZSBsYXN0IHR3byBicmVha2luZyBzcGFjZXMgd2l0aCBuYnNwcyBpZiB0aGUgd29yZHMgYXJlIHNob3J0IGVub3VnaFxuICAgICAgICAgICAgICAvLyB0aGlzIGhlbHBzIHByZXZlbnQgcHNldWRvLXdpZG93cyB3aGVyZSB0aGUgbGFzdCB0d28gd29yZHMgb24gYSBsaW5lIGFyZSBzaG9ydFxuICAgICAgICAgICAgICAvLyBlbm91Z2ggdG8gbG9vayBsaWtlIGEgd2lkb3dcbiAgICAgICAgICAgICAgbGFzdHdvcmQubGVuZ3RoIDwgbWF4TGFzdFdvcmRMZW5ndGggJiZcbiAgICAgICAgICAgICAgcGVudWx0d29yZC5sZW5ndGggPCBtYXhQZW51bHRXb3JkTGVuZ3RoICYmXG4gICAgICAgICAgICAgIGFudGVwZW51bHR3b3JkLmxlbmd0aCA8IG1heEFudGVwZW51bHRXb3JkTGVuZ3RoXG4gICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgZWxlbWVudC5pbm5lckhUTUwgPSBlbC5pbm5lckhUTUwucmVwbGFjZShcbiAgICAgICAgICAgICAgICAvICg/PVteIF0qJCkvaSxcbiAgICAgICAgICAgICAgICBcIlxcdTAwYTBcIlxuICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgICBlbGVtZW50LmlubmVySFRNTCA9IGVsLmlubmVySFRNTC5yZXBsYWNlKFxuICAgICAgICAgICAgICAgIC8gKD89W14gXSokKS9pLFxuICAgICAgICAgICAgICAgIFwiXFx1MDBhMFwiXG4gICAgICAgICAgICAgICk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKFxuICAgICAgICAgICAgICAvLyBvdGhlcndpc2UsIGp1c3QgY3JlYXRlIGFuIG5ic3AgYmV0d2VlbiB0aGUgbGFzdCB0d28gd29yZHMsXG4gICAgICAgICAgICAgIC8vIGFzc3VtaW5nIHRoYXQgdGhleSdyZSBhbHNvIHNob3J0IGVub3VnaFxuICAgICAgICAgICAgICBsYXN0d29yZC5sZW5ndGggPCBtYXhMYXN0V29yZExlbmd0aFR3byAmJlxuICAgICAgICAgICAgICBwZW51bHR3b3JkLmxlbmd0aCA8IG1heFBlbnVsdFdvcmRMZW5ndGhUd29cbiAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAvLyByZXBsYWNlIGxhc3QgYnJlYWtpbmcgc3BhY2Ugd2l0aCBhIG5ic3BcbiAgICAgICAgICAgICAgZWxlbWVudC5pbm5lckhUTUwgPSBlbC5pbm5lckhUTUwucmVwbGFjZShcbiAgICAgICAgICAgICAgICAvICg/PVteIF0qJCkvaSxcbiAgICAgICAgICAgICAgICBcIlxcdTAwYTBcIlxuICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfSk7XG4gIH0gZWxzZSB7XG4gICAgLy8gV2FybiBkZXZlbG9wZXJzIGlmIHRoZXkncmUgdXNpbmcgdGhpcyBpbiB0aGUgd3JvbmcgY29udGV4dC5cbiAgICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgbm8tY29uc29sZVxuICAgIGNvbnNvbGUud2FybihcbiAgICAgIFwidW5XaWRvd2VyQ2xpZW50IGlzIG9ubHkgaW50ZW5kZWQgZm9yIGNsaWVudC1zaWRlIHVzZS4gQ2hlY2sgdGhlIFJFQURNRSBmb3IgbW9yZSBpbmZvLiBJZiB0aGlzIHNjcmlwdCBpcyBydW4gYWdhaW4gY2xpZW50LXNpZGUsIHlvdSBjYW4gaWdub3JlIHRoaXMgbWVzc2FnZS5cIlxuICAgICk7XG4gIH1cbn07XG5cbmV4cG9ydCBkZWZhdWx0IHVuV2lkb3dlckNsaWVudDtcbiJdfQ== |
@@ -8,2 +8,8 @@ "use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/** | ||
@@ -21,22 +27,35 @@ * | ||
* @param {*} html the html | ||
* @param {number} [minWords=4] the minimum number of words before apply the algo | ||
* * params for three word widow removal, all words must be at most this long | ||
* @param {number} [maxLastWordLength=9] | ||
* @param {number} [maxPenultWordLength=4] | ||
* @param {number} [maxAntepenultWordLength=5] | ||
* * params for two word widow removal, if words are too long for three word | ||
* * widow removal, all words must be at most this long | ||
* @param {number} [maxLastWordLengthTwo=13] | ||
* @param {number} [maxPenultWordLengthTwo=11] | ||
* @param {object} [config={ | ||
minWords: 4, | ||
maxLastWordLength: 9, | ||
maxPenultWordLength: 4, | ||
maxAntepenultWordLength: 5, | ||
maxLastWordLengthTwo: 13, | ||
maxPenultWordLengthTwo: 11, | ||
}] the config object | ||
* @returns | ||
*/ | ||
var unWidowerTextOnly = function unWidowerTextOnly(html) { | ||
var minWords = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4; | ||
var maxLastWordLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 9; | ||
var maxPenultWordLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 4; | ||
var maxAntepenultWordLength = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 5; | ||
var maxLastWordLengthTwo = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 13; | ||
var maxPenultWordLengthTwo = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 11; | ||
var unWidowerTextOnly = function unWidowerTextOnly(html, config) { | ||
if (typeof html !== "undefined") { | ||
var defaultConfig = { | ||
minWords: 4, | ||
maxLastWordLength: 9, | ||
// defaults for three-word widow breaker | ||
maxPenultWordLength: 4, | ||
// defaults for three-word widow breaker | ||
maxAntepenultWordLength: 5, | ||
// defaults for two-word widow-breaker | ||
maxLastWordLengthTwo: 13, | ||
// defaults for two-word widow-breaker | ||
maxPenultWordLengthTwo: 11 | ||
}; // merge passed config with default | ||
if (typeof html !== "undefined") { | ||
var _defaultConfig$config = _objectSpread({}, defaultConfig, {}, config), | ||
minWords = _defaultConfig$config.minWords, | ||
maxLastWordLength = _defaultConfig$config.maxLastWordLength, | ||
maxPenultWordLength = _defaultConfig$config.maxPenultWordLength, | ||
maxAntepenultWordLength = _defaultConfig$config.maxAntepenultWordLength, | ||
maxLastWordLengthTwo = _defaultConfig$config.maxLastWordLengthTwo, | ||
maxPenultWordLengthTwo = _defaultConfig$config.maxPenultWordLengthTwo; | ||
var processedText = html; // match all text strings inside html | ||
@@ -82,2 +101,2 @@ | ||
exports["default"] = _default; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91bldpZG93ZXJIdG1sU3RyaW5nLmpzIl0sIm5hbWVzIjpbInVuV2lkb3dlclRleHRPbmx5IiwiaHRtbCIsIm1pbldvcmRzIiwibWF4TGFzdFdvcmRMZW5ndGgiLCJtYXhQZW51bHRXb3JkTGVuZ3RoIiwibWF4QW50ZXBlbnVsdFdvcmRMZW5ndGgiLCJtYXhMYXN0V29yZExlbmd0aFR3byIsIm1heFBlbnVsdFdvcmRMZW5ndGhUd28iLCJwcm9jZXNzZWRUZXh0IiwicmVnZXgiLCJSZWdFeHAiLCJtYXRjaGVzIiwicmVwbGFjZSIsIm1hdGNoIiwibWFwIiwic3RyaW5nIiwibmV3c3RyaW5nIiwic3BsaXRzdHJpbmciLCJzcGxpdCIsImxlbmd0aCIsImxhc3R3b3JkIiwicGVudWx0d29yZCIsImFudGVwZW51bHR3b3JkIiwic3RyaW5nTWF0Y2giXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFBQTs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUF3QkEsSUFBTUEsaUJBQWlCLEdBQUcsU0FBcEJBLGlCQUFvQixDQUN4QkMsSUFEd0IsRUFVckI7QUFBQSxNQVJIQyxRQVFHLHVFQVJRLENBUVI7QUFBQSxNQU5IQyxpQkFNRyx1RUFOaUIsQ0FNakI7QUFBQSxNQUxIQyxtQkFLRyx1RUFMbUIsQ0FLbkI7QUFBQSxNQUpIQyx1QkFJRyx1RUFKdUIsQ0FJdkI7QUFBQSxNQUZIQyxvQkFFRyx1RUFGb0IsRUFFcEI7QUFBQSxNQURIQyxzQkFDRyx1RUFEc0IsRUFDdEI7O0FBQ0gsTUFBSSxPQUFPTixJQUFQLEtBQWdCLFdBQXBCLEVBQWlDO0FBQ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biAgICAgICAgICBjb25zdCBwZW51bHR3b3JkID0gc3BsaXRzdHJpbmdbc3BsaXRzdHJpbmcubGVuZ3RoIC0gMl07XG4gICAgICAgICAgY29uc3QgYW50ZXBlbnVsdHdvcmQgPSBzcGxpdHN0cmluZ1tzcGxpdHN0cmluZy5sZW5ndGggLSAzXTtcbiAgICAgICAgICBpZiAoXG4gICAgICAgICAgICBsYXN0d29yZC5sZW5ndGggPD0gbWF4TGFzdFdvcmRMZW5ndGggJiZcbiAgICAgICAgICAgIHBlbnVsdHdvcmQubGVuZ3RoIDw9IG1heFBlbnVsdFdvcmRMZW5ndGggJiZcbiAgICAgICAgICAgIGFudGVwZW51bHR3b3JkLmxlbmd0aCA8PSBtYXhBbnRlcGVudWx0V29yZExlbmd0aFxuICAgICAgICAgICkge1xuICAgICAgICAgICAgLy8gcmVwbGFjZSBsYXN0IHR3byBicmVha2luZyBzcGFjZXMgd2l0aCBuYnNwc1xuICAgICAgICAgICAgbmV3c3RyaW5nID0gc3RyaW5nLnJlcGxhY2UoLyAoPz1bXiBdKiQpL2ksIFwiXFx1MDBhMFwiKTtcbiAgICAgICAgICAgIG5ld3N0cmluZyA9IHN0cmluZy5yZXBsYWNlKC8gKD89W14gXSokKS9pLCBcIlxcdTAwYTBcIik7XG4gICAgICAgICAgfSBlbHNlIGlmIChcbiAgICAgICAgICAgIGxhc3R3b3JkLmxlbmd0aCA8PSBtYXhMYXN0V29yZExlbmd0aFR3byAmJlxuICAgICAgICAgICAgcGVudWx0d29yZC5sZW5ndGggPD0gbWF4UGVudWx0V29yZExlbmd0aFR3b1xuICAgICAgICAgICkge1xuICAgICAgICAgICAgLy8gcmVwbGFjZSBsYXN0IGJyZWFraW5nIHNwYWNlIHdpdGggYSBuYnNwXG4gICAgICAgICAgICBuZXdzdHJpbmcgPSBzdHJpbmcucmVwbGFjZSgvICg/PVteIF0qJCkvaSwgXCJcXHUwMGEwXCIpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBjb25zdCBzdHJpbmdNYXRjaCA9IG5ldyBSZWdFeHAoYCg/PD0+KSg/ITwpJHtzdHJpbmd9KD89PC8pYCwgXCJnXCIpO1xuICAgICAgICAgIHByb2Nlc3NlZFRleHQgPSBwcm9jZXNzZWRUZXh0LnJlcGxhY2Uoc3RyaW5nTWF0Y2gsIG5ld3N0cmluZyk7XG4gICAgICAgICAgcmV0dXJuIG5ld3N0cmluZztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gbnVsbDtcbiAgICAgIH0pO1xuICAgICAgcmV0dXJuIHByb2Nlc3NlZFRleHQ7XG4gICAgfVxuICB9XG4gIHJldHVybiBodG1sO1xufTtcblxuZXhwb3J0IGRlZmF1bHQgdW5XaWRvd2VyVGV4dE9ubHk7XG4iXX0= |
@@ -18,2 +18,8 @@ "use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/** | ||
@@ -35,11 +41,11 @@ * | ||
* @param {*} children React children node(s) | ||
* @param {number} [minWords=4] the minimum number of words before apply the algo | ||
* @param {object} [config={ | ||
minWords: 4, | ||
maxLastWordLength: 9, | ||
maxPenultWordLength: 4, | ||
maxAntepenultWordLength: 5, | ||
maxLastWordLengthTwo: 13, | ||
maxPenultWordLengthTwo: 11, | ||
}] the config object | ||
* * params for three word widow removal, all words must be at most this long | ||
* @param {number} [maxLastWordLength=9] | ||
* @param {number} [maxPenultWordLength=4] | ||
* @param {number} [maxAntepenultWordLength=5] | ||
* * params for two word widow removal, if words are too long for three word | ||
* * widow removal, all words must be at most this long | ||
* @param {number} [maxLastWordLengthTwo=13] | ||
* @param {number} [maxPenultWordLengthTwo=11] | ||
* @returns | ||
@@ -49,12 +55,23 @@ */ | ||
var children = _ref.children, | ||
minWords = _ref.minWords, | ||
maxLastWordLength = _ref.maxLastWordLength, | ||
maxPenultWordLength = _ref.maxPenultWordLength, | ||
maxAntepenultWordLength = _ref.maxAntepenultWordLength, | ||
maxLastWordLengthTwo = _ref.maxLastWordLengthTwo, | ||
maxPenultWordLengthTwo = _ref.maxPenultWordLengthTwo; | ||
config = _ref.config; | ||
var defaultConfig = { | ||
minWords: 4, | ||
// defaults to 4 | ||
maxLastWordLength: 9, | ||
// defaults for three-word widow breaker | ||
maxPenultWordLength: 4, | ||
// defaults for three-word widow breaker | ||
maxAntepenultWordLength: 5, | ||
// defaults for three-word widow-breaker | ||
maxLastWordLengthTwo: 13, | ||
// defaults for two-word widow-breaker | ||
maxPenultWordLengthTwo: 11 // defaults for two-word widow-breaker | ||
// create unWidow function using params (DRY) | ||
}; // merge passed config with default | ||
var mergedConfig = _objectSpread({}, defaultConfig, {}, config); // create unWidow function using params (DRY) | ||
var unWidowString = function unWidowString(string) { | ||
return (0, _unWidowerText["default"])(string, minWords, maxLastWordLength, maxPenultWordLength, maxAntepenultWordLength, maxLastWordLengthTwo, maxPenultWordLengthTwo); | ||
return (0, _unWidowerText["default"])(string, mergedConfig); | ||
}; // build iterator function | ||
@@ -122,24 +139,10 @@ | ||
UnWidowerReactChildren.defaultProps = { | ||
minWords: 4, | ||
// defaults for three-word widow breaker | ||
maxLastWordLength: 9, | ||
maxPenultWordLength: 4, | ||
maxAntepenultWordLength: 5, | ||
// defaults for two-word widow-breaker | ||
maxLastWordLengthTwo: 13, | ||
maxPenultWordLengthTwo: 11 | ||
config: null | ||
}; | ||
UnWidowerReactChildren.propTypes = { | ||
children: _propTypes["default"].node.isRequired, | ||
minWords: _propTypes["default"].number, | ||
// defaults for three-word widow breaker | ||
maxLastWordLength: _propTypes["default"].number, | ||
maxPenultWordLength: _propTypes["default"].number, | ||
maxAntepenultWordLength: _propTypes["default"].number, | ||
// defaults for two-word widow-breaker | ||
maxLastWordLengthTwo: _propTypes["default"].number, | ||
maxPenultWordLengthTwo: _propTypes["default"].number | ||
config: _propTypes["default"].objectOf(_propTypes["default"].number) | ||
}; | ||
var _default = UnWidowerReactChildren; | ||
exports["default"] = _default; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9VbldpZG93ZXJSZWFjdENoaWxkcmVuLmpzIl0sIm5hbWVzIjpbIlVuV2lkb3dlclJlYWN0Q2hpbGRyZW4iLCJSZWFjdCIsIm1lbW8iLCJjaGlsZHJlbiIsIm1pbldvcmRzIiwibWF4TGFzdFdvcmRMZW5ndGgiLCJtYXhQZW51bHRXb3JkTGVuZ3RoIiwibWF4QW50ZXBlbnVsdFdvcmRMZW5ndGgiLCJtYXhMYXN0V29yZExlbmd0aFR3byIsIm1heFBlbnVsdFdvcmRMZW5ndGhUd28iLCJ1bldpZG93U3RyaW5nIiwic3RyaW5nIiwiaXRlcmF0ZSIsIm5vZGVzIiwiQXJyYXkiLCJpc0FycmF5IiwibWFwIiwibm9kZSIsIm5ld05vZGVzIiwiT2JqZWN0Iiwia2V5cyIsImtleSIsInByb3BzIiwicHJvcCIsIkNoaWxkcmVuIiwiY2hpbGQiLCJ1bldpZG93ZWRDaGlsZCIsImRlZmF1bHRQcm9wcyIsInByb3BUeXBlcyIsImlzUmVxdWlyZWQiLCJudW1iZXIiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFBQTs7QUFD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0+IHtcbiAgICAgIGlmICh0eXBlb2Ygbm9kZXMgIT09IFwidW5kZWZpbmVkXCIpIHtcbiAgICAgICAgLy8gaWYgc3RyaW5nLCBzaW1wbHkgcmVtb3ZlIHRoZSB3aWRvd3NcbiAgICAgICAgaWYgKHR5cGVvZiBub2RlcyA9PT0gXCJzdHJpbmdcIikge1xuICAgICAgICAgIHJldHVybiB1bldpZG93U3RyaW5nKG5vZGVzKTtcbiAgICAgICAgfVxuICAgICAgICAvLyBpdGVyYXRlIGFycmF5IGl0ZW1zIGlmIGFycmF5XG4gICAgICAgIGlmIChBcnJheS5pc0FycmF5KG5vZGVzKSkge1xuICAgICAgICAgIHJldHVybiBub2Rlcy5tYXAobm9kZSA9PiB7XG4gICAgICAgICAgICByZXR1cm4gaXRlcmF0ZShub2RlKTtcbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICAvLyBpdGVyYXRlIG92ZXIgYXJyYXkvb2JqZWN0XG4gICAgICAgIGlmICh0eXBlb2Ygbm9kZXMgPT09IFwib2JqZWN0XCIpIHtcbiAgICAgICAgICAvLyBjcmVhdGUgbmV3IG9iamVjdCBmb3IgaXRlcmF0ZWQgaXRlbXNcbiAgICAgICAgICBjb25zdCBuZXdOb2RlcyA9IHt9O1xuICAgICAgICAgIC8vIGxvb3AgdGhyb3VnaCBvYmplY3QgdG8gYnVpbGQgbmV3IGl0ZW1cbiAgICAgICAgICBPYmplY3Qua2V5cyhub2RlcykubWFwKGtleSA9PiB7XG4gICAgICAgICAgICBpZiAoa2V5ID09PSBcInByb3BzXCIpIHtcbiAgICAgICAgICAgICAgbmV3Tm9kZXMucHJvcHMgPSB7fTtcbiAgICAgICAgICAgICAgY29uc3QgcHJvcHMgPSBub2Rlc1trZXldO1xuICAgICAgICAgICAgICBpZiAodHlwZW9mIHByb3BzICE9PSBcInVuZGVmaW5lZFwiKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5rZXlzKHByb3BzKS5tYXAocHJvcCA9PiB7XG4gICAgICAgICAgICAgICAgICBpZiAoXG4gICAgICAgICAgICAgICAgICAgIHR5cGVvZiBwcm9wc1twcm9wXSAhPT0gXCJ1bmRlZmluZWRcIiAmJlxuICAgICAgICAgICAgICAgICAgICBwcm9wID09PSBcImNoaWxkcmVuXCJcbiAgICAgICAgICAgICAgICAgICkge1xuICAgICAgICAgICAgICAgICAgICAvLyBjb25zb2xlLmxvZyhjaGlsZE5vZGVzKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkocHJvcHNbcHJvcF0pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZXMucHJvcHNbcHJvcF0gPSBpdGVyYXRlKHByb3BzW3Byb3BdKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHByb3BzW3Byb3BdID09PSBcIm9iamVjdFwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZXMucHJvcHNbcHJvcF0gPSBpdGVyYXRlKHByb3BzW3Byb3BdKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgbmV3Tm9kZXMucHJvcHNbcHJvcF0gPSBwcm9wc1twcm9wXTtcbiAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgbmV3Tm9kZXNba2V5XSA9IG5vZGVzW2tleV07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSk7XG4gICAgICAgICAgcmV0dXJuIG5ld05vZGVzO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICByZXR1cm4gbnVsbDtcbiAgICB9O1xuICAgIC8vIHJldHVybiBjb21wb25lbnRcbiAgICByZXR1cm4gUmVhY3QuQ2hpbGRyZW4ubWFwKGNo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5tYXAoa2V5ID0+IHtcbiAgICAgICAgICBpZiAoa2V5ID09PSBcInByb3BzXCIpIHtcbiAgICAgICAgICAgIG5ld05vZGVzLnByb3BzID0ge307XG4gICAgICAgICAgICBjb25zdCBwcm9wcyA9IG5vZGVzW2tleV07XG4gICAgICAgICAgICBpZiAodHlwZW9mIHByb3BzICE9PSBcInVuZGVmaW5lZFwiKSB7XG4gICAgICAgICAgICAgIHJldHVybiBPYmplY3Qua2V5cyhwcm9wcykubWFwKHByb3AgPT4ge1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcHJvcHNbcHJvcF0gIT09IFwidW5kZWZpbmVkXCIgJiYgcHJvcCA9PT0gXCJjaGlsZHJlblwiKSB7XG4gICAgICAgICAgICAgICAgICAvLyBjb25zb2xlLmxvZyhjaGlsZE5vZGVzKTtcbiAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KHByb3BzW3Byb3BdKSkge1xuICAgICAgICAgICAgICAgICAgICBuZXdOb2Rlcy5wcm9wc1twcm9wXSA9IGl0ZXJhdGUocHJvcHNbcHJvcF0pO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBwcm9wc1twcm9wXSA9PT0gXCJvYmplY3RcIikge1xuICAgICAgICAgICAgICAgICAgICBuZXdOb2Rlcy5wcm9wc1twcm9wXSA9IGl0ZXJhdGUocHJvcHNbcHJvcF0pO1xuICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICBuZXdOb2Rlcy5wcm9wc1twcm9wXSA9IHByb3BzW3Byb3BdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIG5ld05vZGVzW2tleV0gPSBub2Rlc1trZXldO1xuICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgICAgIHJldHVybiBuZXdOb2RlcztcbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIG51bGw7XG4gIH07XG4gIC8vIHJldHVybiBjb21wb25lbnRcbiAgcmV0dXJuIFJlYWN0LkNoaWxkcmVuLm1hcChjaGlsZHJlbiwgY2hpbGQgPT4ge1xuICAgIGNvbnN0IHVuV2lkb3dlZENoaWxkID0gaXRlcmF0ZShjaGlsZCk7XG4gICAgcmV0dXJuIHVuV2lkb3dlZENoaWxkO1xuICB9KTtcbn0pO1xuXG5VbldpZG93ZXJSZWFjdENoaWxkcmVuLmRlZmF1bHRQcm9wcyA9IHtcbiAgY29uZmlnOiBudWxsLFxufTtcblxuVW5XaWRvd2VyUmVhY3RDaGlsZHJlbi5wcm9wVHlwZXMgPSB7XG4gIGNoaWxkcmVuOiBwcm9wVHlwZXMubm9kZS5pc1JlcXVpcmVkLFxuICBjb25maWc6IHByb3BUeXBlcy5vYmplY3RPZihwcm9wVHlwZXMubnVtYmVyKSxcbn07XG5cbmV4cG9ydCBkZWZhdWx0IFVuV2lkb3dlclJlYWN0Q2hpbGRyZW47XG4iXX0= |
@@ -8,2 +8,8 @@ "use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/** | ||
@@ -20,22 +26,35 @@ * | ||
* @param {*} text the text | ||
* @param {number} [minWords=4] the minimum number of words before apply the algo | ||
* * params for three word widow removal, all words must be at most this long | ||
* @param {number} [maxLastWordLength=9] | ||
* @param {number} [maxPenultWordLength=4] | ||
* @param {number} [maxAntepenultWordLength=5] | ||
* * params for two word widow removal, if words are too long for three word | ||
* * widow removal, all words must be at most this long | ||
* @param {number} [maxLastWordLengthTwo=13] | ||
* @param {number} [maxPenultWordLengthTwo=11] | ||
* @param {object} [config={ | ||
minWords: 4, | ||
maxLastWordLength: 9, | ||
maxPenultWordLength: 4, | ||
maxAntepenultWordLength: 5, | ||
maxLastWordLengthTwo: 13, | ||
maxPenultWordLengthTwo: 11, | ||
}] the config object | ||
* @returns | ||
*/ | ||
var unWidowerTextOnly = function unWidowerTextOnly(text) { | ||
var minWords = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4; | ||
var maxLastWordLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 9; | ||
var maxPenultWordLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 4; | ||
var maxAntepenultWordLength = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 5; | ||
var maxLastWordLengthTwo = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 13; | ||
var maxPenultWordLengthTwo = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 11; | ||
var unWidowerTextOnly = function unWidowerTextOnly(text, config) { | ||
if (typeof text !== "undefined") { | ||
var defaultConfig = { | ||
minWords: 4, | ||
maxLastWordLength: 9, | ||
// defaults for three-word widow breaker | ||
maxPenultWordLength: 4, | ||
// defaults for three-word widow breaker | ||
maxAntepenultWordLength: 5, | ||
// defaults for two-word widow-breaker | ||
maxLastWordLengthTwo: 13, | ||
// defaults for two-word widow-breaker | ||
maxPenultWordLengthTwo: 11 | ||
}; // merge passed config with default | ||
if (typeof text !== "undefined") { | ||
var _defaultConfig$config = _objectSpread({}, defaultConfig, {}, config), | ||
minWords = _defaultConfig$config.minWords, | ||
maxLastWordLength = _defaultConfig$config.maxLastWordLength, | ||
maxPenultWordLength = _defaultConfig$config.maxPenultWordLength, | ||
maxAntepenultWordLength = _defaultConfig$config.maxAntepenultWordLength, | ||
maxLastWordLengthTwo = _defaultConfig$config.maxLastWordLengthTwo, | ||
maxPenultWordLengthTwo = _defaultConfig$config.maxPenultWordLengthTwo; | ||
var processedText = text; // match all text strings inside text | ||
@@ -73,2 +92,2 @@ | ||
exports["default"] = _default; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91bldpZG93ZXJUZXh0LmpzIl0sIm5hbWVzIjpbInVuV2lkb3dlclRleHRPbmx5IiwidGV4dCIsIm1pbldvcmRzIiwibWF4TGFzdFdvcmRMZW5ndGgiLCJtYXhQZW51bHRXb3JkTGVuZ3RoIiwibWF4QW50ZXBlbnVsdFdvcmRMZW5ndGgiLCJtYXhMYXN0V29yZExlbmd0aFR3byIsIm1heFBlbnVsdFdvcmRMZW5ndGhUd28iLCJwcm9jZXNzZWRUZXh0IiwibmV3c3RyaW5nIiwic3BsaXRzdHJpbmciLCJzcGxpdCIsImxlbmd0aCIsImxhc3R3b3JkIiwicGVudWx0d29yZCIsImFudGVwZW51bHR3b3JkIiwicmVwbGFjZSIsInN0cmluZ01hdGNoIiwiUmVnRXhwIl0sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBQUE7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUF1QkEsSUFBTUEsaUJBQWlCLEdBQUcsU0FBcEJBLGlCQUFvQixDQUN4QkMsSUFEd0IsRUFVckI7QUFBQSxNQVJIQyxRQVFHLHVFQVJRLENBUVI7QUFBQSxNQU5IQyxpQkFNRyx1RUFOaUIsQ0FNakI7QUFBQSxNQUxIQyxtQkFLRyx1RUFMbUIsQ0FLbk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DBhMFwiKTtcbiAgICAgICAgbmV3c3RyaW5nID0gdGV4dC5yZXBsYWNlKC8gKD89W14gXSokKS9pLCBcIlxcdTAwYTBcIik7XG4gICAgICB9IGVsc2UgaWYgKFxuICAgICAgICBsYXN0d29yZC5sZW5ndGggPD0gbWF4TGFzdFdvcmRMZW5ndGhUd28gJiZcbiAgICAgICAgcGVudWx0d29yZC5sZW5ndGggPD0gbWF4UGVudWx0V29yZExlbmd0aFR3b1xuICAgICAgKSB7XG4gICAgICAgIC8vIHJlcGxhY2UgbGFzdCBicmVha2luZyBzcGFjZSB3aXRoIGEgbmJzcFxuICAgICAgICBuZXdzdHJpbmcgPSB0ZXh0LnJlcGxhY2UoLyAoPz1bXiBdKiQpL2ksIFwiXFx1MDBhMFwiKTtcbiAgICAgIH1cbiAgICAgIGNvbnN0IHN0cmluZ01hdGNoID0gbmV3IFJlZ0V4cCh0ZXh0LCBcImdcIik7XG4gICAgICBwcm9jZXNzZWRUZXh0ID0gcHJvY2Vzc2VkVGV4dC5yZXBsYWNlKHN0cmluZ01hdGNoLCBuZXdzdHJpbmcpO1xuICAgICAgcmV0dXJuIG5ld3N0cmluZztcbiAgICB9XG4gICAgcmV0dXJuIHByb2Nlc3NlZFRleHQ7XG4gIH1cbiAgcmV0dXJuIG51bGw7XG59O1xuXG5leHBvcnQgZGVmYXVsdCB1bldpZG93ZXJUZXh0T25seTtcbiJdfQ== |
{ | ||
"name": "@designbycosmic/cosmic-unwidower", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "source": "src/index.js", |
127
README.md
@@ -8,2 +8,21 @@ # cosmic-unWidower | ||
## Config | ||
All functions use the same config settings: | ||
```javascript | ||
{ | ||
minWords: 4, | ||
// for three word widow removal, all words must be at most this long | ||
maxLastWordLength: 9, | ||
maxPenultWordLength: 4, | ||
maxAntepenultWordLength: 5, | ||
// for two word widow removal, all words must be at most this long | ||
maxLastWordLengthTwo: 13, | ||
maxPenultWordLengthTwo: 11, | ||
} | ||
``` | ||
--- | ||
## unWidowerClient | ||
@@ -15,16 +34,4 @@ | ||
* `minWords` Number | ||
the minimum number of words before apply the algo, default | ||
* `config` Object see config object above | ||
*Params for three word widow removal, all words must be at most this long* | ||
* `maxLastWordLength` | ||
* `maxPenultWordLength` | ||
* `maxAntepenultWordLength` | ||
*Params for two word widow removal, if words are too long for three word widow removal, all words must be at most this long* | ||
* `maxLastWordLengthTwo` | ||
* `maxPenultWordLengthTwo` | ||
### Examples | ||
@@ -39,3 +46,12 @@ | ||
unWidower(); | ||
const config = { | ||
minWords: 4, | ||
maxLastWordLength: 9, // defaults for three-word widow breaker | ||
maxPenultWordLength: 4, // defaults for three-word widow breaker | ||
maxAntepenultWordLength: 5, // defaults for three-word widow-breaker | ||
maxLastWordLengthTwo: 13, // defaults for two-word widow-breaker | ||
maxPenultWordLengthTwo: 11, // defaults for two-word widow-breaker | ||
}; | ||
unWidower(config); | ||
``` | ||
@@ -53,4 +69,13 @@ | ||
const config = { | ||
minWords: 4, | ||
maxLastWordLength: 9, // defaults for three-word widow breaker | ||
maxPenultWordLength: 4, // defaults for three-word widow breaker | ||
maxAntepenultWordLength: 5, // defaults for three-word widow-breaker | ||
maxLastWordLengthTwo: 13, // defaults for two-word widow-breaker | ||
maxPenultWordLengthTwo: 11, // defaults for two-word widow-breaker | ||
}; | ||
useEffect(() => { | ||
unWidowerClient(5, 6, 5, 4, 11, 9); | ||
unWidowerClient(config); | ||
}, []); | ||
@@ -72,15 +97,4 @@ | ||
* `html` a string of html code | ||
* `minWords` the minimum number of words before apply the algo | ||
*Params for three word widow removal, all words must be at most this long* | ||
* `config` Object see config object above | ||
* `maxLastWordLength` | ||
* `maxPenultWordLength` | ||
* `maxAntepenultWordLength` | ||
*Params for two word widow removal, if words are too long for three word widow removal, all words must be at most this long* | ||
* `maxLastWordLengthTwo` | ||
* `maxPenultWordLengthTwo` | ||
### Example | ||
@@ -98,4 +112,13 @@ | ||
const content = unWidowerHtmlString(html, 5, 6, 5, 4, 11, 9); | ||
const config = { | ||
minWords: 4, | ||
maxLastWordLength: 9, // defaults for three-word widow breaker | ||
maxPenultWordLength: 4, // defaults for three-word widow breaker | ||
maxAntepenultWordLength: 5, // defaults for three-word widow-breaker | ||
maxLastWordLengthTwo: 13, // defaults for two-word widow-breaker | ||
maxPenultWordLengthTwo: 11, // defaults for two-word widow-breaker | ||
}; | ||
const content = unWidowerHtmlString(html, config); | ||
return <div dangerouslySetInnerHTML={{__html: content}} />; | ||
@@ -115,15 +138,4 @@ | ||
* `text` a text string | ||
* `minWords` the minimum number of words before apply the algo | ||
*Params for three word widow removal, all words must be at most this long* | ||
* `config` Object see config object above | ||
* `maxLastWordLength` | ||
* `maxPenultWordLength` | ||
* `maxAntepenultWordLength` | ||
*Params for two word widow removal, if words are too long for three word widow removal, all words must be at most this long* | ||
* `maxLastWordLengthTwo` | ||
* `maxPenultWordLengthTwo` | ||
### Example | ||
@@ -141,4 +153,13 @@ | ||
const content = unWidowerText(text, 5, 6, 5, 4, 11, 9); | ||
const config = { | ||
minWords: 4, | ||
maxLastWordLength: 9, // defaults for three-word widow breaker | ||
maxPenultWordLength: 4, // defaults for three-word widow breaker | ||
maxAntepenultWordLength: 5, // defaults for three-word widow-breaker | ||
maxLastWordLengthTwo: 13, // defaults for two-word widow-breaker | ||
maxPenultWordLengthTwo: 11, // defaults for two-word widow-breaker | ||
}; | ||
const content = unWidowerText(text, config); | ||
return <p>{content}</p>; | ||
@@ -160,15 +181,4 @@ | ||
* `children` is a node of React children | ||
* `minWords` the minimum number of words before apply the algo | ||
*Params for three word widow removal, all words must be at most this long* | ||
* `config` Object see config object above | ||
* `maxLastWordLength` | ||
* `maxPenultWordLength` | ||
* `maxAntepenultWordLength` | ||
*Params for two word widow removal, if words are too long for three word widow removal, all words must be at most this long* | ||
* `maxLastWordLengthTwo` | ||
* `maxPenultWordLengthTwo` | ||
### Example | ||
@@ -181,6 +191,13 @@ | ||
export default ({children}) => { | ||
const config = { | ||
minWords: 4, | ||
maxLastWordLength: 9, // defaults for three-word widow breaker | ||
maxPenultWordLength: 4, // defaults for three-word widow breaker | ||
maxAntepenultWordLength: 5, // defaults for three-word widow-breaker | ||
maxLastWordLengthTwo: 13, // defaults for two-word widow-breaker | ||
maxPenultWordLengthTwo: 11, // defaults for two-word widow-breaker | ||
}; | ||
return <UnWidowerReactChildren config={config}>{children}</UnWidowerReactChildren>; | ||
return <UnWidowerReactChildren>{children}</UnWidowerReactChildren>; | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68979
472
194
1