UNPKG

seo-editor

Version:

Copywriting keyword to-do list automation

18 lines (16 loc) 2.76 kB
/** * @name seo-editor * @fileoverview Copywriting keyword to-do list automation * @version 2.0.8 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/seo-editor/} */ "use strict";var seoEditor=(()=>{var b=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var k=(t,o)=>{for(var l in o)b(t,l,{get:o[l],enumerable:!0})},C=(t,o,l,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of w(o))!N.call(t,e)&&e!==l&&b(t,e,{get:()=>o[e],enumerable:!(n=O(o,e))||n.enumerable});return t};var J=t=>C(b({},"__esModule",{value:!0}),t);var T={};k(T,{editor:()=>R,isLetter:()=>c,setLengthCompensation:()=>f,version:()=>p});var L="2.0.8";var p=L;function c(t){return typeof t=="string"&&t.length===1&&t.toUpperCase()!==t.toLowerCase()}function f(t,o){var l,n;for(let e=t.length;e--&&((n=(l=t[e])==null?void 0:l.counts)!=null&&n.length);)t[e].lengthCompensation=o-t[e].length;return t}var D=/[a-zA-Z0-9_'\u0392-\u03c9\u0400-\u04FF\u0027]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|[\u00E4\u00C4\u00E5\u00C5\u00F6\u00D6]+|[\u0531-\u0556\u0561-\u0586\u0559\u055A\u055B]+|\w+/g;function A(t){return t.split(/\r?\n/).filter(o=>!o.trim().startsWith("#")&&!o.trim().startsWith(">")).join(` `).trim()}function y(t){return typeof t=="string"&&t.trim().startsWith("- ")}function R(t="",o=""){let l=Date.now(),n=o.split(/^[ \t]*---+/m).map(s=>A(s).toLowerCase()).filter(s=>s.trim()),e=[],r=0,h=0,E=n.length?n.map(()=>0):[0],d=t.toLowerCase().split(/\r?\n/);return t.trim()?(d.forEach((s,$)=>{var x;if(y(s)){h++;let i=s.trim().slice(2).trim(),{length:V}=i;r=Math.max(r,i.length),e.push({extracted:i,length:V,counts:n.map((u,S)=>{if(!u.includes(i))return 0;let g=0,a=0;for(;u.includes(i,a);){let m=u.indexOf(i,a);!c(u[m-1])&&(!c(u[m+i.length])||u[m+i.length].toLowerCase()==="s"&&!c(u[m+i.length+1]))&&(g+=1),a+=m+i.length}return g&&(E[S]+=1),g}),lengthCompensation:r})}else(x=e[~-e.length])!=null&&x.counts.length&&(e=f(e,r)),e.push({extracted:"",counts:[],length:0,lengthCompensation:0}),r=0}),y(d[~-d.length])&&(e=f(e,r)),{todoLines:e,chunkWordCounts:n.map(s=>{var $;return(($=s.match(D))==null?void 0:$.length)||0}),chunkLengths:n.map(s=>s.length),todoTotal:h,completion:E,log:{timeTakenInMilliseconds:Date.now()-l,version:p}}):{todoLines:[],chunkWordCounts:n.map(s=>{var $;return(($=s.match(D))==null?void 0:$.length)||0}),chunkLengths:n.map(s=>s.length),todoTotal:0,completion:n.length?n.map(()=>0):[0],log:{timeTakenInMilliseconds:Date.now()-l,version:p}}}return J(T);})(); /*! * word-regex <https://github.com/jonschlinkert/word-regex> * * Copyright (c) 2015 Jon Schlinkert. * Licensed under the MIT license. */