Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typeit

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typeit - npm Package Compare versions

Comparing version 8.3.3 to 8.4.0

5

dist/index.d.ts

@@ -1,3 +0,4 @@

import { Element, Options } from "./types";
import { Options, TypeItInstance } from "./types";
export declare type TypeItOptions = Options;
export default function TypeIt(element: Element | string, options?: Options): void;
declare const TypeIt: TypeItInstance;
export default TypeIt;

27

dist/index.es.js

@@ -271,3 +271,3 @@ // TypeIt by Alex MacArthur - https://typeitjs.com

};
function TypeIt(element, options = {}) {
const TypeIt = function(element, options = {}) {
let _wait = async (callback, delay, silent = false) => {

@@ -302,14 +302,7 @@ if (_statuses.frozen) {

let _generateTemporaryOptionQueueItems = (newOptions = {}) => {
return [
() => _options(newOptions),
() => _options(_opts)
];
return [() => _options(newOptions), () => _options(_opts)];
};
let _addSplitPause = (items) => {
let delay = _opts.nextStringDelay;
_queue.add([
() => _pause(delay[0]),
...items,
() => _pause(delay[1])
]);
_queue.add([() => _pause(delay[0]), ...items, () => _pause(delay[1])]);
};

@@ -371,5 +364,3 @@ let _setUpCursor = () => {

expandTextNodes(_element);
_addSplitPause([
() => _delete({ num: null })
]);
_addSplitPause([() => _delete({ num: null })]);
return strings;

@@ -514,3 +505,3 @@ }

let bookEndQueueItems = _generateTemporaryOptionQueueItems(actionOpts);
return _queueAndReturn([bookEndQueueItems[0], func, bookEndQueueItems[1]], actionOpts);
return _queueAndReturn([bookEndQueueItems[0], () => func(this), bookEndQueueItems[1]], actionOpts);
};

@@ -526,7 +517,3 @@ this.move = function(movementArg, actionOpts = {}) {

};
return _queueAndReturn([
bookEndQueueItems[0],
() => _move(moveArgs),
bookEndQueueItems[1]
], actionOpts);
return _queueAndReturn([bookEndQueueItems[0], () => _move(moveArgs), bookEndQueueItems[1]], actionOpts);
};

@@ -616,3 +603,3 @@ this.options = function(opts) {

}
}
};
export { TypeIt as default };
// TypeIt by Alex MacArthur - https://typeitjs.com
(function(v,_){typeof exports=="object"&&typeof module!="undefined"?module.exports=_():typeof define=="function"&&define.amd?define(_):(v=typeof globalThis!="undefined"?globalThis:v||self,v.TypeIt=_())})(this,function(){"use strict";var v=e=>Array.isArray(e),_=e=>v(e)?e:[e];let ne=function(e){let r=function(a){return p=p.concat(_(a)),this},l=function(a,y){p[a]=y},i=function(){p=p.map(a=>(delete a.done,a))},u=function(){p=[],r(e)},d=(a=!1)=>p.filter(y=>a||!y.done),g=a=>{p[a].done=!0},p=[];return r(e),{add:r,set:l,reset:i,wipe:u,getItems:d,markDone:g}};var V=e=>Array.from(e),$=e=>document.createTextNode(e);let R=e=>([...e.childNodes].forEach(r=>{if(r.nodeValue){[...r.nodeValue].forEach(l=>{r.parentNode.insertBefore($(l),r)}),r.remove();return}R(r)}),e);var q=e=>{let r=document.implementation.createHTMLDocument();return r.body.innerHTML=e,R(r.body)};const j="data-typeit-id",C="ti-cursor",H="START",le="END",ie={started:!1,completed:!1,frozen:!1,destroyed:!1},se={breakLines:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}};function B(e,r=!1){let l=document.createTreeWalker(e,NodeFilter.SHOW_ALL,{acceptNode:d=>{var g;return((g=d==null?void 0:d.classList)==null?void 0:g.contains(C))?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),i,u=[];for(;i=l.nextNode();)i.originalParent=i.parentNode,u.push(i);return r?u.reverse():u}function oe(e){return B(q(e))}function W(e,r=!0){return r?oe(e):V(e).map($)}var L=e=>document.createElement(e),J=(e,r="")=>{let l=L("style");l.id=r,l.appendChild($(e)),document.head.appendChild(l)};let Y=e=>Number.isInteger(e),I=(e,r=document,l=!1)=>r[`querySelector${l?"All":""}`](e);var F=e=>"value"in e;let G=e=>F(e)?V(e.value):B(e,!0).filter(r=>!(r.childNodes.length>0)),ae=(e,r,l=H)=>{let i=new RegExp(le,"i").test(l),u=e?I(e,r):r,d=B(u,!0),g=d[0],p=d[d.length-1],y=i&&!e?0:G(r).findIndex(x=>x.isSameNode(i?g:p));return i&&y--,y+1};var K=({el:e,move:r,cursorPos:l,to:i})=>Y(r)?r*-1:ae(r,e,i)-l,X=e=>(v(e)||(e=[e/2,e/2]),e),Z=(e,r)=>Math.abs(Math.random()*(e+r-(e-r))+(e-r));let ee=e=>e/2;function ue(e){let{speed:r,deleteSpeed:l,lifeLike:i}=e;return l=l!==null?l:r/3,i?[Z(r,ee(r)),Z(l,ee(l))]:[r,l]}var de=e=>(e.forEach(r=>clearTimeout(r)),[]),fe=()=>Math.random().toString().substring(2,9),ce=(e,r)=>{new IntersectionObserver((i,u)=>{i.forEach(d=>{d.isIntersecting&&(r(),u.unobserve(e))})},{threshold:1}).observe(e)};let E=e=>typeof e=="function"?e():e,he=e=>(e==null?void 0:e.tagName)==="BODY",pe=(e,r)=>{if(F(e)){e.value=`${e.value}${r.textContent}`;return}r.innerHTML="";let l=he(r.originalParent)?e:r.originalParent||e;l.insertBefore(r,I("."+C,l)||null)},me=(e,r,l)=>Math.min(Math.max(r+e,0),l.length);var k=(e,r)=>Object.assign({},e,r),Q=e=>{if(!e)return;let r=e.parentNode;(r.childNodes.length>1?e:r).remove()},ye=(e,r,l)=>{let i=r[l-1],u=I(`.${C}`,e);e=(i==null?void 0:i.parentNode)||e,e.insertBefore(u,i||null)};function ge(e){return typeof e=="string"?I(e):e}let Se=e=>/<(.+)>(.*?)<\/(.+)>/.test(e.outerHTML),be=async(e,r,l)=>new Promise(i=>{let u=async()=>{await e(),i()};l.push(setTimeout(u,r))}),Te={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"},ve=(e,r,l)=>{let u=`${`[${j}='${e}']`} .${C}`,d=getComputedStyle(l),g=Object.entries(Te).reduce((p,[a,y])=>`${p} ${a}: var(--ti-cursor-${a}, ${y||d[a]});`,"");J(`@keyframes blink-${e} { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ${u} { display: inline; letter-spacing: -1em; ${g} animation: blink-${e} ${r.cursorSpeed/1e3}s infinite; } ${u}.with-delay { animation-delay: 500ms; } ${u}.disabled { animation: none; }`,e)};function _e(e,r={}){let l=async(t,n,o=!1)=>{b.frozen&&await new Promise(h=>{this.unfreeze=()=>{b.frozen=!1,h()}}),o||await s.beforeStep(this),await be(t,n,U),o||await s.afterStep(this)},i=()=>F(f),u=t=>ue(s)[t],d=()=>G(f),g=(t,n=0)=>t?u(n):0,p=(t={})=>{let n=t.delay;n&&S.add(()=>w(n))},a=(t,n)=>(S.add(t),p(n),this),y=(t={})=>[()=>P(t),()=>P(s)],x=t=>{let n=s.nextStringDelay;S.add([()=>w(n[0]),...t,()=>w(n[1])])},Ee=()=>{if(i())return;let t=L("span");return t.className=C,O?(t.innerHTML=q(s.cursorChar).innerHTML,t):(t.style.visibility="hidden",t)},we=async()=>{!i()&&f.appendChild(M),O&&ve(re,s,f)},A=t=>{O&&(M.classList.toggle("disabled",t),M.classList.toggle("with-delay",!t))},Ce=()=>{let t=s.strings.filter(n=>!!n);t.forEach((n,o)=>{let h=W(n,s.html);if(S.add(()=>D({chars:h})),o+1===t.length)return;let c=[s.breakLines?()=>D({chars:[L("BR")],silent:!0}):()=>N({num:h.length})];x(c)})},Ne=async t=>{T&&await te({value:T}),S.reset(),S.set(0,()=>w(t)),await N({num:null})},Le=t=>{let n=f.innerHTML;return n?(f.innerHTML="",s.startDelete?(f.innerHTML=n,R(f),x([()=>N({num:null})]),t):n.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(t)):t},z=async()=>{b.started=!0;let t=S.getItems();try{for(let o=0;o<t.length;o++)await t[o](),S.markDone(o),A(!1);if(b.completed=!0,await s.afterComplete(this),!s.loop)throw"";let n=s.loopDelay;l(async()=>{await Ne(n[0]),z()},n[1])}catch{}return this},w=(t=0)=>l(()=>{},t),te=async({value:t,to:n=H,instant:o=!1})=>{A(!0);let h=K({el:f,move:t,cursorPos:T,to:n}),c=()=>{T=me(h<0?-1:1,T,d()),ye(f,d(),T)};await l(async()=>{for(let m=0;m<Math.abs(h);m++)o?c():await l(c,u(0))},g(o))},D=({chars:t,silent:n=!1,instant:o=!1})=>(A(!0),l(async()=>{let h=c=>pe(f,c);n||await s.beforeString(t,this);for(let c of t)o||Se(c)?h(c):await l(()=>h(c),u(0));n||await s.afterString(t,this)},g(o),!0)),P=async t=>{s=k(s,t)},Ie=async()=>{if(i()){f.value="";return}d().forEach(t=>{Q(t)})},N=async({num:t=null,instant:n=!1,to:o=H})=>{A(!0),await l(async()=>{let h=(()=>t===null?d().length:Y(t)?t:K({el:f,move:t,cursorPos:T,to:o}))(),c=()=>{let m=d();!m.length||(i()?f.value=f.value.slice(0,-1):Q(m[T]))};for(let m=0;m<h;m++)n?c():await l(c,u(1))},g(n,1)),t===null&&d().length-1>0&&await N({num:null})};this.break=function(t){return a(()=>D({chars:[L("BR")],silent:!0}),t)},this.delete=function(t=null,n={}){t=E(t);let o=y(n),h=t,{instant:c,to:m}=n;return a([o[0],()=>N({num:h,instant:c,to:m}),o[1]],n)},this.empty=function(t={}){return a(Ie,t)},this.exec=function(t,n){let o=y(n);return a([o[0],t,o[1]],n)},this.move=function(t,n={}){t=E(t);let o=y(n),{instant:h,to:c}=n,m={value:t===null?"":t,to:c,instant:h};return a([o[0],()=>te(m),o[1]],n)},this.options=function(t){return t=E(t),a(()=>P(t),t)},this.pause=function(t,n={}){return a(()=>w(E(t)),n)},this.type=function(t,n={}){t=E(t);let o=y(n),h=W(t,s.html),{instant:c}=n,m=[o[0],()=>D({chars:h,instant:c}),o[1]];return a(m,n)},this.is=function(t){return b[t]},this.destroy=function(t=!0){U=de(U),E(t)&&Q(M),b.destroyed=!0},this.freeze=function(){b.frozen=!0},this.unfreeze=function(){},this.reset=function(t){!this.is("destroyed")&&this.destroy(),t?(S.wipe(),t(this)):S.reset(),T=0;for(let n in b)b[n]=!1;return f[i()?"value":"innerHTML"]="",this},this.go=function(){return b.started?this:(we(),s.waitUntilVisible?(ce(f,z.bind(this)),this):(z(),this))},this.getQueue=()=>S,this.getOptions=()=>s,this.updateOptions=t=>P(t),this.getElement=()=>f;let f=ge(e),U=[],T=0,b=k({},ie),s=k(se,r);s=k(s,{html:!i()&&s.html,nextStringDelay:X(s.nextStringDelay),loopDelay:X(s.loopDelay)});let re=fe(),S=ne([()=>w(s.startDelay)]);f.dataset.typeitId=re,J(`[${j}]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}`);let O=s.cursor&&!i(),M=Ee();s.strings=Le(_(s.strings)),s.strings.length&&Ce()}return _e});
(function(v,_){typeof exports=="object"&&typeof module!="undefined"?module.exports=_():typeof define=="function"&&define.amd?define(_):(v=typeof globalThis!="undefined"?globalThis:v||self,v.TypeIt=_())})(this,function(){"use strict";var v=e=>Array.isArray(e),_=e=>v(e)?e:[e];let ne=function(e){let r=function(a){return p=p.concat(_(a)),this},l=function(a,m){p[a]=m},i=function(){p=p.map(a=>(delete a.done,a))},u=function(){p=[],r(e)},d=(a=!1)=>p.filter(m=>a||!m.done),g=a=>{p[a].done=!0},p=[];return r(e),{add:r,set:l,reset:i,wipe:u,getItems:d,markDone:g}};var V=e=>Array.from(e),$=e=>document.createTextNode(e);let R=e=>([...e.childNodes].forEach(r=>{if(r.nodeValue){[...r.nodeValue].forEach(l=>{r.parentNode.insertBefore($(l),r)}),r.remove();return}R(r)}),e);var q=e=>{let r=document.implementation.createHTMLDocument();return r.body.innerHTML=e,R(r.body)};const j="data-typeit-id",C="ti-cursor",H="START",le="END",ie={started:!1,completed:!1,frozen:!1,destroyed:!1},se={breakLines:!0,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,html:!0,lifeLike:!0,loop:!1,loopDelay:750,nextStringDelay:750,speed:100,startDelay:250,startDelete:!1,strings:[],waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}};function B(e,r=!1){let l=document.createTreeWalker(e,NodeFilter.SHOW_ALL,{acceptNode:d=>{var g;return((g=d==null?void 0:d.classList)==null?void 0:g.contains(C))?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),i,u=[];for(;i=l.nextNode();)i.originalParent=i.parentNode,u.push(i);return r?u.reverse():u}function oe(e){return B(q(e))}function W(e,r=!0){return r?oe(e):V(e).map($)}var I=e=>document.createElement(e),J=(e,r="")=>{let l=I("style");l.id=r,l.appendChild($(e)),document.head.appendChild(l)};let Y=e=>Number.isInteger(e),L=(e,r=document,l=!1)=>r[`querySelector${l?"All":""}`](e);var F=e=>"value"in e;let G=e=>F(e)?V(e.value):B(e,!0).filter(r=>!(r.childNodes.length>0)),ae=(e,r,l=H)=>{let i=new RegExp(le,"i").test(l),u=e?L(e,r):r,d=B(u,!0),g=d[0],p=d[d.length-1],m=i&&!e?0:G(r).findIndex(x=>x.isSameNode(i?g:p));return i&&m--,m+1};var K=({el:e,move:r,cursorPos:l,to:i})=>Y(r)?r*-1:ae(r,e,i)-l,X=e=>(v(e)||(e=[e/2,e/2]),e),Z=(e,r)=>Math.abs(Math.random()*(e+r-(e-r))+(e-r));let ee=e=>e/2;function ue(e){let{speed:r,deleteSpeed:l,lifeLike:i}=e;return l=l!==null?l:r/3,i?[Z(r,ee(r)),Z(l,ee(l))]:[r,l]}var de=e=>(e.forEach(r=>clearTimeout(r)),[]),fe=()=>Math.random().toString().substring(2,9),ce=(e,r)=>{new IntersectionObserver((i,u)=>{i.forEach(d=>{d.isIntersecting&&(r(),u.unobserve(e))})},{threshold:1}).observe(e)};let E=e=>typeof e=="function"?e():e,he=e=>(e==null?void 0:e.tagName)==="BODY",pe=(e,r)=>{if(F(e)){e.value=`${e.value}${r.textContent}`;return}r.innerHTML="";let l=he(r.originalParent)?e:r.originalParent||e;l.insertBefore(r,L("."+C,l)||null)},ye=(e,r,l)=>Math.min(Math.max(r+e,0),l.length);var k=(e,r)=>Object.assign({},e,r),Q=e=>{if(!e)return;let r=e.parentNode;(r.childNodes.length>1?e:r).remove()},me=(e,r,l)=>{let i=r[l-1],u=L(`.${C}`,e);e=(i==null?void 0:i.parentNode)||e,e.insertBefore(u,i||null)};function ge(e){return typeof e=="string"?L(e):e}let Se=e=>/<(.+)>(.*?)<\/(.+)>/.test(e.outerHTML),be=async(e,r,l)=>new Promise(i=>{let u=async()=>{await e(),i()};l.push(setTimeout(u,r))}),Te={"font-family":"","font-weight":"","font-size":"","font-style":"","line-height":"",color:"","margin-left":"-.125em","margin-right":".125em"},ve=(e,r,l)=>{let u=`${`[${j}='${e}']`} .${C}`,d=getComputedStyle(l),g=Object.entries(Te).reduce((p,[a,m])=>`${p} ${a}: var(--ti-cursor-${a}, ${m||d[a]});`,"");J(`@keyframes blink-${e} { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} } ${u} { display: inline; letter-spacing: -1em; ${g} animation: blink-${e} ${r.cursorSpeed/1e3}s infinite; } ${u}.with-delay { animation-delay: 500ms; } ${u}.disabled { animation: none; }`,e)};return function(e,r={}){let l=async(t,n,o=!1)=>{b.frozen&&await new Promise(h=>{this.unfreeze=()=>{b.frozen=!1,h()}}),o||await s.beforeStep(this),await be(t,n,U),o||await s.afterStep(this)},i=()=>F(f),u=t=>ue(s)[t],d=()=>G(f),g=(t,n=0)=>t?u(n):0,p=(t={})=>{let n=t.delay;n&&S.add(()=>w(n))},a=(t,n)=>(S.add(t),p(n),this),m=(t={})=>[()=>P(t),()=>P(s)],x=t=>{let n=s.nextStringDelay;S.add([()=>w(n[0]),...t,()=>w(n[1])])},_e=()=>{if(i())return;let t=I("span");return t.className=C,O?(t.innerHTML=q(s.cursorChar).innerHTML,t):(t.style.visibility="hidden",t)},Ee=async()=>{!i()&&f.appendChild(M),O&&ve(re,s,f)},A=t=>{O&&(M.classList.toggle("disabled",t),M.classList.toggle("with-delay",!t))},we=()=>{let t=s.strings.filter(n=>!!n);t.forEach((n,o)=>{let h=W(n,s.html);if(S.add(()=>D({chars:h})),o+1===t.length)return;let c=[s.breakLines?()=>D({chars:[I("BR")],silent:!0}):()=>N({num:h.length})];x(c)})},Ce=async t=>{T&&await te({value:T}),S.reset(),S.set(0,()=>w(t)),await N({num:null})},Ne=t=>{let n=f.innerHTML;return n?(f.innerHTML="",s.startDelete?(f.innerHTML=n,R(f),x([()=>N({num:null})]),t):n.trim().split(/<br(?:\s*?)(?:\/)?>/).concat(t)):t},z=async()=>{b.started=!0;let t=S.getItems();try{for(let o=0;o<t.length;o++)await t[o](),S.markDone(o),A(!1);if(b.completed=!0,await s.afterComplete(this),!s.loop)throw"";let n=s.loopDelay;l(async()=>{await Ce(n[0]),z()},n[1])}catch{}return this},w=(t=0)=>l(()=>{},t),te=async({value:t,to:n=H,instant:o=!1})=>{A(!0);let h=K({el:f,move:t,cursorPos:T,to:n}),c=()=>{T=ye(h<0?-1:1,T,d()),me(f,d(),T)};await l(async()=>{for(let y=0;y<Math.abs(h);y++)o?c():await l(c,u(0))},g(o))},D=({chars:t,silent:n=!1,instant:o=!1})=>(A(!0),l(async()=>{let h=c=>pe(f,c);n||await s.beforeString(t,this);for(let c of t)o||Se(c)?h(c):await l(()=>h(c),u(0));n||await s.afterString(t,this)},g(o),!0)),P=async t=>{s=k(s,t)},Ie=async()=>{if(i()){f.value="";return}d().forEach(t=>{Q(t)})},N=async({num:t=null,instant:n=!1,to:o=H})=>{A(!0),await l(async()=>{let h=(()=>t===null?d().length:Y(t)?t:K({el:f,move:t,cursorPos:T,to:o}))(),c=()=>{let y=d();!y.length||(i()?f.value=f.value.slice(0,-1):Q(y[T]))};for(let y=0;y<h;y++)n?c():await l(c,u(1))},g(n,1)),t===null&&d().length-1>0&&await N({num:null})};this.break=function(t){return a(()=>D({chars:[I("BR")],silent:!0}),t)},this.delete=function(t=null,n={}){t=E(t);let o=m(n),h=t,{instant:c,to:y}=n;return a([o[0],()=>N({num:h,instant:c,to:y}),o[1]],n)},this.empty=function(t={}){return a(Ie,t)},this.exec=function(t,n){let o=m(n);return a([o[0],()=>t(this),o[1]],n)},this.move=function(t,n={}){t=E(t);let o=m(n),{instant:h,to:c}=n,y={value:t===null?"":t,to:c,instant:h};return a([o[0],()=>te(y),o[1]],n)},this.options=function(t){return t=E(t),a(()=>P(t),t)},this.pause=function(t,n={}){return a(()=>w(E(t)),n)},this.type=function(t,n={}){t=E(t);let o=m(n),h=W(t,s.html),{instant:c}=n,y=[o[0],()=>D({chars:h,instant:c}),o[1]];return a(y,n)},this.is=function(t){return b[t]},this.destroy=function(t=!0){U=de(U),E(t)&&Q(M),b.destroyed=!0},this.freeze=function(){b.frozen=!0},this.unfreeze=function(){},this.reset=function(t){!this.is("destroyed")&&this.destroy(),t?(S.wipe(),t(this)):S.reset(),T=0;for(let n in b)b[n]=!1;return f[i()?"value":"innerHTML"]="",this},this.go=function(){return b.started?this:(Ee(),s.waitUntilVisible?(ce(f,z.bind(this)),this):(z(),this))},this.getQueue=()=>S,this.getOptions=()=>s,this.updateOptions=t=>P(t),this.getElement=()=>f;let f=ge(e),U=[],T=0,b=k({},ie),s=k(se,r);s=k(s,{html:!i()&&s.html,nextStringDelay:X(s.nextStringDelay),loopDelay:X(s.loopDelay)});let re=fe(),S=ne([()=>w(s.startDelay)]);f.dataset.typeitId=re,J(`[${j}]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}`);let O=s.cursor&&!i(),M=_e();s.strings=Ne(_(s.strings)),s.strings.length&&we()}});

@@ -0,1 +1,2 @@

export declare type TypeItInstance = (element: Element | string, options: Options) => void;
export declare type Character = {

@@ -2,0 +3,0 @@ node: Node | null;

{
"name": "typeit",
"version": "8.3.3",
"version": "8.4.0",
"description": "The most versatile animated typing utility on the planet.",

@@ -5,0 +5,0 @@ "author": "Alex MacArthur <alex@macarthur.me> (https://macarthur.me)",

@@ -27,10 +27,4 @@ import Queue from "./Queue";

import { setCursorStyles } from "./helpers/setCursorStyles";
import { Element, Options, QueueItem, ActionOpts, Sides, TypeItInstance } from "./types";
import {
Element,
Options,
QueueItem,
ActionOpts,
Sides,
} from "./types";
import {
CURSOR_CLASS,

@@ -46,6 +40,3 @@ DEFAULT_STATUSES,

export default function TypeIt(
element: Element | string,
options: Options = {}
): void {
const TypeIt: TypeItInstance = function (element, options = {}) {
let _wait = async (

@@ -97,6 +88,3 @@ callback: Function,

): QueueItem[] => {
return [
() => _options(newOptions),
() => _options(_opts)
];
return [() => _options(newOptions), () => _options(_opts)];
};

@@ -111,7 +99,3 @@

_queue.add([
() => _pause(delay[0]),
...items,
() => _pause(delay[1])
]);
_queue.add([() => _pause(delay[0]), ...items, () => _pause(delay[1])]);
};

@@ -173,3 +157,3 @@

_queue.add(() => _type({chars}));
_queue.add(() => _type({ chars }));

@@ -182,8 +166,9 @@ // This is the last string. Get outta here.

let splitPauseArgs: QueueItem[] = [
_opts.breakLines
? () => _type({
chars: [createElement("BR")],
silent: true,
})
: () => _delete({ num: chars.length })
_opts.breakLines
? () =>
_type({
chars: [createElement("BR")],
silent: true,
})
: () => _delete({ num: chars.length }),
];

@@ -222,5 +207,3 @@

_addSplitPause([
() => _delete({ num: null})
]);
_addSplitPause([() => _delete({ num: null })]);

@@ -282,3 +265,3 @@ return strings;

}): Promise<void> => {
_disableCursorBlink(true)
_disableCursorBlink(true);

@@ -331,4 +314,3 @@ let numberOfSteps = calculateCursorSteps({

async () => {
let insert = (character) =>
insertIntoElement(_element, character);
let insert = (character) => insertIntoElement(_element, character);

@@ -384,7 +366,7 @@ silent || (await _opts.beforeString(chars, this));

let rounds = (() => {
if(num === null) {
return _getAllChars().length
if (num === null) {
return _getAllChars().length;
}
if(isNumber(num)) {
if (isNumber(num)) {
return num;

@@ -395,7 +377,7 @@ }

return calculateCursorSteps({
el: _element,
move: num,
cursorPos: _cursorPosition,
to,
});
el: _element,
move: num,
cursorPos: _cursorPosition,
to,
});
})();

@@ -460,6 +442,6 @@

this.exec = function (func: () => any, actionOpts) {
this.exec = function (func: (instance: TypeItInstance) => any, actionOpts) {
let bookEndQueueItems = _generateTemporaryOptionQueueItems(actionOpts);
return _queueAndReturn(
[bookEndQueueItems[0], func, bookEndQueueItems[1]],
[bookEndQueueItems[0], () => func(this), bookEndQueueItems[1]],
actionOpts

@@ -484,7 +466,3 @@ );

return _queueAndReturn(
[
bookEndQueueItems[0],
() => _move(moveArgs),
bookEndQueueItems[1],
],
[bookEndQueueItems[0], () => _move(moveArgs), bookEndQueueItems[1]],
actionOpts

@@ -554,6 +532,6 @@ );

// If provided, the queue can be totally regenerated.
if(rebuild) {
if (rebuild) {
_queue.wipe();
rebuild(this);
} else {
} else {
_queue.reset();

@@ -611,3 +589,3 @@ }

let _id = generateHash();
let _queue = Queue([() => _pause(_opts.startDelay) ]);
let _queue = Queue([() => _pause(_opts.startDelay)]);
_element.dataset.typeitId = _id;

@@ -631,2 +609,4 @@

}
}
};
export default TypeIt;

@@ -0,1 +1,6 @@

export type TypeItInstance = (
element: Element | string,
options: Options
) => void;
export type Character = {

@@ -36,10 +41,13 @@ node: Node | null;

export type QueueItem = Function & {
done?: boolean
}
export type Element = HTMLElement & CharacterData & Node & ChildNode & {
value: string | number;
originalParent?: HTMLElement;
done?: boolean;
};
export type Element = HTMLElement &
CharacterData &
Node &
ChildNode & {
value: string | number;
originalParent?: HTMLElement;
};
export type Sides = "START" | "END";
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc