UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 1.22 kB
import{copy as e}from"../../libs/i18n/copy.mjs";import t from"../errors/lucid-error.mjs";import{translate as n}from"../../libs/i18n/translate.mjs";const r=`0123456789abcdefghijklmnopqrstuvwxyz`,i=(r,i)=>{throw new t({message:n(e(r,{data:i})),scope:`fractional-order`,data:i})},a=e=>{if(e.length===0||e.endsWith(r[0]))return!1;for(let t of e)if(!r.includes(t))return!1;return!0},o=(e,t)=>{if(t!==null&&e>=t&&i(`server:core.documents.order.fractional.bounds.invalid`,{lower:e,upper:t}),t!==null){let n=0;for(;(e.charAt(n)||r[0])===t.charAt(n);)n++;if(n>0)return t.slice(0,n)+o(e.slice(n),t.slice(n))}let n=e?r.indexOf(e.charAt(0)):0,a=t===null?36:r.indexOf(t.charAt(0));if(a-n>1){let e=Math.round(.5*(n+a));return r.charAt(e)}return t!==null&&t.length>1?t.slice(0,1):r.charAt(n)+o(e.slice(1),null)},s=(e,t)=>(e!==null&&!a(e)&&i(`server:core.documents.order.fractional.key.invalid`,{key:e}),t!==null&&!a(t)&&i(`server:core.documents.order.fractional.key.invalid`,{key:t}),e!==null&&t!==null&&e>=t&&i(`server:core.documents.order.fractional.bounds.invalid`,{lower:e,upper:t}),o(e??``,t)),c=e=>typeof e==`string`&&a(e);export{s as generateKeyBetween,c as isFractionalOrderKey}; //# sourceMappingURL=fractional-order.mjs.map