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

@skeletonizer/utils

Package Overview
Dependencies
Maintainers
0
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@skeletonizer/utils - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

5

dist/src/models/schema-item.model.d.ts

@@ -20,2 +20,7 @@ type TSchemaInstance<T> = InstanceType<typeof SchemaItem<T>>;

}>): TSchemaInstance<Date>;
timeOfDay(this: TSchemaInstance<Date | undefined>, config?: Partial<{
use12HourFormat: boolean;
showSeconds: boolean;
showAmPm: boolean;
}>): TSchemaInstance<string>;
uuid(this: TSchemaInstance<number | undefined>): TSchemaInstance<number>;

@@ -22,0 +27,0 @@ boolean(this: TSchemaInstance<boolean | undefined>): TSchemaInstance<boolean>;

4

dist/utils.umd.js

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

(function(s,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(s=typeof globalThis<"u"?globalThis:s||self,a(s["@skeletonizer/utils"]={}))})(this,function(s){"use strict";var M=s=>{throw TypeError(s)};var A=(s,a,r)=>a.has(s)||M("Cannot "+r);var h=(s,a,r)=>(A(s,a,"read from private field"),r?r.call(s):a.get(s)),w=(s,a,r)=>a.has(s)?M("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(s):a.set(s,r),l=(s,a,r,d)=>(A(s,a,"write to private field"),d?d.call(s,r):a.set(s,r),r);var i;const a=["Lorem","ipsum","dolor","sit","amet,","consectetur","adipiscing","elit.","Mauris","posuere","tincidunt","purus,","id","laoreet","mauris","cursus","nec.","Quisque","id","ante","id","tellus","aliquam","pulvinar","eget","eu","dolor.","Donec","egestas","dapibus","massa,","vel","finibus","lectus","congue","eu.","Morbi","quis","erat","condimentum,","molestie","ex","a,","sollicitudin","metus.","Vestibulum","orci","metus,","sagittis","a","sagittis","a,","varius","id","diam.","Cras","egestas","eros","vestibulum,","tempus","ipsum","pellentesque,","dictum","justo.","Quisque","sed","justo","metus.","Suspendisse","id","felis","vitae","nunc","auctor","tristique","eu","sit","amet","mi.","Ut","luctus","posuere","viverra.","Nunc","sed","augue","a","velit","sodales","iaculis.","Sed","at","arcu","non","massa","hendrerit","scelerisque.","Nunc","commodo","vulputate","vestibulum.","Duis","ut","leo","nisi.","Mauris","dignissim","quis","sem","non","blandit.","Suspendisse","id","elit","eget","leo","efficitur","maximus.","Ut","eu","auctor","ligula.","Nulla","in","leo","luctus,","tempor","justo","vitae,","condimentum","massa.","Quisque","venenatis","elementum","posuere.","Sed","bibendum","bibendum","enim,","in","faucibus","ante.","Aliquam","pretium","sapien","ac","eleifend","suscipit.","Duis","lacinia","justo","quis","diam","elementum,","vitae","fringilla","lectus","faucibus.","Integer","dictum","commodo","diam","a","tempus.","Aenean","elementum","egestas","quam,","eget","feugiat","ligula","imperdiet","vitae.","Morbi","mattis","dui","sed","elementum","mollis.","In","interdum","viverra","urna,","at","scelerisque","sapien.","Sed","molestie","blandit","risus","nec","ornare.","Integer","pharetra","massa","purus,","ut","fringilla","augue","sollicitudin","in.","Pellentesque","eu","leo","pharetra,","hendrerit","lectus","id,","dapibus","ipsum.","Quisque","tincidunt","euismod","venenatis.","Sed","lacus","ex,","pulvinar","at","dui","vitae,","condimentum","rutrum","eros.","Nunc","viverra","cursus","ante,","ac","dapibus","ligula","volutpat","nec.","Integer","commodo","in","tortor","eget","aliquet.","Nam","bibendum","lectus","vitae","ligula","interdum","scelerisque.","Morbi","sit","amet","augue","diam.","Etiam","purus","lorem,","sodales","sed","sodales","ac,","dignissim","a","tellus.","Nunc","vehicula","nibh","in","erat","rhoncus","ullamcorper.","Orci","varius","natoque","penatibus","et","magnis","dis","parturient","montes,","nascetur","ridiculus","mus.","Aliquam","augue","nunc,","fringilla","at","dictum","quis,","luctus","sit","amet","nisl.","Nam","lectus","felis,","egestas","nec","lacinia","non,","auctor","eget","lorem.","Nunc","vel","velit","quis","magna","hendrerit","volutpat","in","nec","leo.","Aenean","tempor","lectus","tortor,","nec","bibendum","elit","aliquam","at.","In","id","libero","tincidunt,","interdum","libero","sit","amet,","gravida","est.","Morbi","ut","ipsum","enim.","Duis","vel","posuere","ante.","Praesent","sollicitudin","lacus","sit","amet","luctus","euismod.","Phasellus","lorem","elit,","auctor","sed","risus","a,","faucibus","tempor","lacus.","Integer","id","tellus","ut","eros","congue","ornare.","Cras","vitae","ornare","sem.","Cras","tincidunt","arcu","efficitur","mauris","molestie,","eu","eleifend","eros","mattis.","Integer","id","diam","mauris.","Duis","suscipit","enim","risus,","non","dignissim","nulla","imperdiet","hendrerit.","Vestibulum","sed","dignissim","erat.","Aliquam","erat","volutpat.","Nunc","mattis","auctor","justo,","non","fringilla","dolor","blandit","a.","Donec","et","velit","tristique","lacus","varius","aliquam.","Praesent","ac","molestie","quam,","vitae","scelerisque","tellus.","Praesent","eleifend","sed","diam","in","gravida.","Donec","tristique","sapien","ante,","in","egestas","diam","porta","ac.","Proin","ac","justo","eleifend,","consequat","ante","vitae,","laoreet","augue.","Mauris","scelerisque","arcu","dolor,","quis","lobortis","risus","pellentesque","eu.","Praesent","in","enim","a","elit","feugiat","dapibus.","Duis","quis","bibendum","mi.","Vestibulum","lacinia,","sem","at","efficitur","volutpat,","velit","ligula","vulputate","nisi,","sit","amet","dapibus","risus","metus","sed","est.","Sed","in","venenatis","ante.","Pellentesque","vel","ipsum","pharetra,","efficitur","quam","ut,","hendrerit","dolor."];var r=(u=>(u.Text="text",u.Input="input",u.Image="image",u.Video="video",u.WrapperElement="wrapper-element",u))(r||{}),d=(u=>(u.PrimaryColor="rgba(100, 100, 100, .6)",u.SecondaryColor="rgba(100, 100, 100, .3)",u))(d||{});class v{static daysInMs(e){return e*24*60*60*1e3}static dateBetween(e,t){return new Date(e.getTime()+Math.random()*(t.getTime()-e.getTime()))}}let T=0;class q{constructor(){w(this,i)}get value(){return h(this,i)}words(e){this.assertType();let t="",n=0;for(;n<e;)t+=this.randomLoremWord()+" ",n++;return l(this,i,t.trim()),this}paragraphs(e){this.assertType();let t="",n=0;const b=50;for(;n<e;){const p=b-Math.round(b*Math.random()*.2)*(Math.random()<.5?-1:1);t+=this.words(p).value,n!==e-1&&(t+=`
`),n++}return l(this,i,t),this}number(e=0,t=1e3){return this.assertType(),l(this,i,Math.ceil(Math.random()*(t-e))+e),this}currency(e){return this.assertType(),l(this,i,new Intl.NumberFormat(e.locale,{...e.options,style:"currency",currency:e.currency}).format(+h(this,i))),this}multiply(e){return this.assertType(),l(this,i,h(this,i)*e),this}date(e={}){this.assertType();let t=e.max??new Date("2100-01-01"),n=e.min??new Date("1970-01-01");return e.isFuture?n=new Date(Date.now()+v.daysInMs(1)):e.isPast&&(t=new Date(Date.now()-v.daysInMs(1))),l(this,i,v.dateBetween(n,t)),this}uuid(){return T++,this.assertType(),l(this,i,T),this}boolean(){return this.assertType(),l(this,i,Math.random()<=.5),this}symbol(e=0){return this.assertType(),l(this,i,Symbol(e)),this}randomItem(e){this.assertType();const t=Math.floor(Math.random()*e.length);return l(this,i,e[t]),this}prefix(e){return this.assertType(),l(this,i,`${e}${h(this,i)}`),this}suffix(e){return this.assertType(),l(this,i,`${h(this,i)}${e}`),this}identical(e){return this.assertType(),l(this,i,e),this}assertType(){}randomLoremWord(){const e=Math.floor(Math.random()*a.length);return a[e]??"lorem"}}i=new WeakMap;let x=0;class c{constructor(e){this.generator=e,this.uuid=x++,this.viewModel=this.generator(),this.val=c.modelToValue(this.viewModel)}get value(){return this.val}static modelToValue(e){if(e instanceof q)return e.value;if(Array.isArray(e))return e.map(this.modelToValue);{const t={};return Object.keys(e).forEach(n=>{t[n]=c.modelToValue(e[n])}),t}}}class I{proxy(e){return e instanceof c?e.value:e}}class C{constructor(){this.config=null,this.viewModels=[]}setupModels(){if(this.config){const e=this.config.schemaGenerator;this.viewModels=Array.from({length:this.config.repeat},()=>new c(e))}}}const m=class m{static skeletonizeProjectedTemplate(e,t){const n=(t==null?void 0:t.primaryColor)??d.PrimaryColor,b=(t==null?void 0:t.secondaryColor)??d.SecondaryColor;e.setAttribute("style",`--skeletonizer-primary-color: ${n}; --skeletonizer-secondary-color: ${b};`),Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach(p=>{const P=["br","b","strong","i","em","mark","small","del","ins","sub","sup"],y=Array.from(p.childNodes).map(o=>o.nodeName.toLowerCase()).filter(o=>!P.includes(o)),k=y.length>0&&y.some(o=>o!==y[0]);p.childNodes.forEach(o=>{switch(o.nodeName.toLowerCase()){case"#text":{if(this.assertAs(o),o.wholeText.trim())if(k){const g=document.createElement("span");g.innerText=o.cloneNode().wholeText,g.innerText.length&&o.replaceWith(m.skeletonizedSpanGenerator(g.innerText,r.Text))}else{const g=m.skeletonizedSpanGenerator(p.innerHTML,r.Text);p.innerHTML=g.outerHTML}break}case"input":{o.setAttribute(m.dataAttr,r.Input);break}case"img":{o.setAttribute(m.dataAttr,r.Image);break}case"video":{o.setAttribute(m.dataAttr,r.Video);break}}})}),e.setAttribute(m.dataAttr,r.WrapperElement)}static skeletonizedSpanGenerator(e,t){const n=document.createElement("span");return n.innerHTML=e,n.setAttribute(m.dataAttr,t),n}static assertAs(e){}};m.dataAttr="data-skeletonizer";let f=m;s.Schema=c,s.SchemaItem=q,s.SkeletonAbstractComponent=I,s.SkeletonAdapterComponent=C,s.SkeletonDirective=f,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
(function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s["@skeletonizer/utils"]={}))})(this,function(s){"use strict";var A=s=>{throw TypeError(s)};var w=(s,r,n)=>r.has(s)||A("Cannot "+n);var c=(s,r,n)=>(w(s,r,"read from private field"),n?n.call(s):r.get(s)),x=(s,r,n)=>r.has(s)?A("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(s):r.set(s,n),u=(s,r,n,g)=>(w(s,r,"write to private field"),g?g.call(s,n):r.set(s,n),n);var i;const r=["Lorem","ipsum","dolor","sit","amet,","consectetur","adipiscing","elit.","Mauris","posuere","tincidunt","purus,","id","laoreet","mauris","cursus","nec.","Quisque","id","ante","id","tellus","aliquam","pulvinar","eget","eu","dolor.","Donec","egestas","dapibus","massa,","vel","finibus","lectus","congue","eu.","Morbi","quis","erat","condimentum,","molestie","ex","a,","sollicitudin","metus.","Vestibulum","orci","metus,","sagittis","a","sagittis","a,","varius","id","diam.","Cras","egestas","eros","vestibulum,","tempus","ipsum","pellentesque,","dictum","justo.","Quisque","sed","justo","metus.","Suspendisse","id","felis","vitae","nunc","auctor","tristique","eu","sit","amet","mi.","Ut","luctus","posuere","viverra.","Nunc","sed","augue","a","velit","sodales","iaculis.","Sed","at","arcu","non","massa","hendrerit","scelerisque.","Nunc","commodo","vulputate","vestibulum.","Duis","ut","leo","nisi.","Mauris","dignissim","quis","sem","non","blandit.","Suspendisse","id","elit","eget","leo","efficitur","maximus.","Ut","eu","auctor","ligula.","Nulla","in","leo","luctus,","tempor","justo","vitae,","condimentum","massa.","Quisque","venenatis","elementum","posuere.","Sed","bibendum","bibendum","enim,","in","faucibus","ante.","Aliquam","pretium","sapien","ac","eleifend","suscipit.","Duis","lacinia","justo","quis","diam","elementum,","vitae","fringilla","lectus","faucibus.","Integer","dictum","commodo","diam","a","tempus.","Aenean","elementum","egestas","quam,","eget","feugiat","ligula","imperdiet","vitae.","Morbi","mattis","dui","sed","elementum","mollis.","In","interdum","viverra","urna,","at","scelerisque","sapien.","Sed","molestie","blandit","risus","nec","ornare.","Integer","pharetra","massa","purus,","ut","fringilla","augue","sollicitudin","in.","Pellentesque","eu","leo","pharetra,","hendrerit","lectus","id,","dapibus","ipsum.","Quisque","tincidunt","euismod","venenatis.","Sed","lacus","ex,","pulvinar","at","dui","vitae,","condimentum","rutrum","eros.","Nunc","viverra","cursus","ante,","ac","dapibus","ligula","volutpat","nec.","Integer","commodo","in","tortor","eget","aliquet.","Nam","bibendum","lectus","vitae","ligula","interdum","scelerisque.","Morbi","sit","amet","augue","diam.","Etiam","purus","lorem,","sodales","sed","sodales","ac,","dignissim","a","tellus.","Nunc","vehicula","nibh","in","erat","rhoncus","ullamcorper.","Orci","varius","natoque","penatibus","et","magnis","dis","parturient","montes,","nascetur","ridiculus","mus.","Aliquam","augue","nunc,","fringilla","at","dictum","quis,","luctus","sit","amet","nisl.","Nam","lectus","felis,","egestas","nec","lacinia","non,","auctor","eget","lorem.","Nunc","vel","velit","quis","magna","hendrerit","volutpat","in","nec","leo.","Aenean","tempor","lectus","tortor,","nec","bibendum","elit","aliquam","at.","In","id","libero","tincidunt,","interdum","libero","sit","amet,","gravida","est.","Morbi","ut","ipsum","enim.","Duis","vel","posuere","ante.","Praesent","sollicitudin","lacus","sit","amet","luctus","euismod.","Phasellus","lorem","elit,","auctor","sed","risus","a,","faucibus","tempor","lacus.","Integer","id","tellus","ut","eros","congue","ornare.","Cras","vitae","ornare","sem.","Cras","tincidunt","arcu","efficitur","mauris","molestie,","eu","eleifend","eros","mattis.","Integer","id","diam","mauris.","Duis","suscipit","enim","risus,","non","dignissim","nulla","imperdiet","hendrerit.","Vestibulum","sed","dignissim","erat.","Aliquam","erat","volutpat.","Nunc","mattis","auctor","justo,","non","fringilla","dolor","blandit","a.","Donec","et","velit","tristique","lacus","varius","aliquam.","Praesent","ac","molestie","quam,","vitae","scelerisque","tellus.","Praesent","eleifend","sed","diam","in","gravida.","Donec","tristique","sapien","ante,","in","egestas","diam","porta","ac.","Proin","ac","justo","eleifend,","consequat","ante","vitae,","laoreet","augue.","Mauris","scelerisque","arcu","dolor,","quis","lobortis","risus","pellentesque","eu.","Praesent","in","enim","a","elit","feugiat","dapibus.","Duis","quis","bibendum","mi.","Vestibulum","lacinia,","sem","at","efficitur","volutpat,","velit","ligula","vulputate","nisi,","sit","amet","dapibus","risus","metus","sed","est.","Sed","in","venenatis","ante.","Pellentesque","vel","ipsum","pharetra,","efficitur","quam","ut,","hendrerit","dolor."];var n=(o=>(o.Text="text",o.Input="input",o.Image="image",o.Video="video",o.WrapperElement="wrapper-element",o))(n||{}),g=(o=>(o.PrimaryColor="rgba(100, 100, 100, .6)",o.SecondaryColor="rgba(100, 100, 100, .3)",o))(g||{});class f{static daysInMs(e){return e*24*60*60*1e3}static dateBetween(e,t){return new Date(e.getTime()+Math.random()*(t.getTime()-e.getTime()))}}let M=0;class q{constructor(){x(this,i)}get value(){return c(this,i)}words(e){this.assertType();let t="",a=0;for(;a<e;)t+=this.randomLoremWord()+" ",a++;return u(this,i,t.trim()),this}paragraphs(e){this.assertType();let t="",a=0;const p=50;for(;a<e;){const d=p-Math.round(p*Math.random()*.2)*(Math.random()<.5?-1:1);t+=this.words(d).value,a!==e-1&&(t+=`
`),a++}return u(this,i,t),this}number(e=0,t=1e3){return this.assertType(),u(this,i,Math.ceil(Math.random()*(t-e))+e),this}currency(e){return this.assertType(),u(this,i,new Intl.NumberFormat(e.locale,{...e.options,style:"currency",currency:e.currency}).format(+c(this,i))),this}multiply(e){return this.assertType(),u(this,i,c(this,i)*e),this}date(e={}){this.assertType();let t=e.max??new Date("2100-01-01"),a=e.min??new Date("1970-01-01");return e.isFuture?a=new Date(Date.now()+f.daysInMs(1)):e.isPast&&(t=new Date(Date.now()-f.daysInMs(1))),u(this,i,f.dateBetween(a,t)),this}timeOfDay(e={}){const t=c(this,i)??this.date().value;this.assertType();const a=(e.use12HourFormat?t.getUTCHours()%12:t.getUTCHours()).toString().padStart(2,"0"),p=t.getMinutes().toString().padStart(2,"0"),d=t.getSeconds().toString().padStart(2,"0"),h=this;return u(h,i,e.showSeconds?`${a}:${p}:${d}`:`${a}:${p}`),e.showAmPm&&u(h,i,c(h,i)+(t.getUTCHours()>=12?" PM":" AM")),h}uuid(){return M++,this.assertType(),u(this,i,M),this}boolean(){return this.assertType(),u(this,i,Math.random()<=.5),this}symbol(e=0){return this.assertType(),u(this,i,Symbol(e)),this}randomItem(e){this.assertType();const t=Math.floor(Math.random()*e.length);return u(this,i,e[t]),this}prefix(e){return this.assertType(),u(this,i,`${e}${c(this,i)}`),this}suffix(e){return this.assertType(),u(this,i,`${c(this,i)}${e}`),this}identical(e){return this.assertType(),u(this,i,e),this}assertType(){}randomLoremWord(){const e=Math.floor(Math.random()*r.length);return r[e]??"lorem"}}i=new WeakMap;let C=0;class b{constructor(e){this.generator=e,this.uuid=C++,this.viewModel=this.generator(),this.val=b.modelToValue(this.viewModel)}get value(){return this.val}static modelToValue(e){if(e instanceof q)return e.value;if(Array.isArray(e))return e.map(this.modelToValue);{const t={};return Object.keys(e).forEach(a=>{t[a]=b.modelToValue(e[a])}),t}}}class I{proxy(e){return e instanceof b?e.value:e}}class P{constructor(){this.config=null,this.viewModels=[]}setupModels(){if(this.config){const e=this.config.schemaGenerator;this.viewModels=Array.from({length:this.config.repeat},()=>new b(e))}}}const m=class m{static skeletonizeProjectedTemplate(e,t){const a=(t==null?void 0:t.primaryColor)??g.PrimaryColor,p=(t==null?void 0:t.secondaryColor)??g.SecondaryColor;e.setAttribute("style",`--skeletonizer-primary-color: ${a}; --skeletonizer-secondary-color: ${p};`),Array.from(e.querySelectorAll("*:not(svg, [data-skeletonizer])")).forEach(d=>{const h=["br","b","strong","i","em","mark","small","del","ins","sub","sup"],T=Array.from(d.childNodes).map(l=>l.nodeName.toLowerCase()).filter(l=>!h.includes(l)),S=T.length>0&&T.some(l=>l!==T[0]);d.childNodes.forEach(l=>{switch(l.nodeName.toLowerCase()){case"#text":{if(this.assertAs(l),l.wholeText.trim())if(S){const v=document.createElement("span");v.innerText=l.cloneNode().wholeText,v.innerText.length&&l.replaceWith(m.skeletonizedSpanGenerator(v.innerText,n.Text))}else{const v=m.skeletonizedSpanGenerator(d.innerHTML,n.Text);d.innerHTML=v.outerHTML}break}case"input":{l.setAttribute(m.dataAttr,n.Input);break}case"img":{l.setAttribute(m.dataAttr,n.Image);break}case"video":{l.setAttribute(m.dataAttr,n.Video);break}}})}),e.setAttribute(m.dataAttr,n.WrapperElement)}static skeletonizedSpanGenerator(e,t){const a=document.createElement("span");return a.innerHTML=e,a.setAttribute(m.dataAttr,t),a}static assertAs(e){}};m.dataAttr="data-skeletonizer";let y=m;s.Schema=b,s.SchemaItem=q,s.SkeletonAbstractComponent=I,s.SkeletonAdapterComponent=P,s.SkeletonDirective=y,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
{
"name": "@skeletonizer/utils",
"version": "1.2.0",
"version": "1.3.0",
"description": "Utils for all skeletonizer packages",

@@ -58,3 +58,3 @@ "author": "Luka Varga",

},
"gitHead": "fd61bebc869a7867b27c5f757961eaaa889c0021"
"gitHead": "f92c5f202d62cb226317cf0c9a0a59e0921f5470"
}
# `@skeletonizer/utils`
[![codecov](https://codecov.io/github/lukaVarga/skeletonizer/graph/badge.svg?token=4YZYRB9UN7)](https://codecov.io/github/lukaVarga/skeletonizer?style=for-the-badge)
![NPM Downloads](https://img.shields.io/npm/dy/%40skeletonizer%2Futils?style=for-the-badge&labelColor=%23444&color=%23090)
This is the general utility package for the Skeletonizer project. It should be used together with every adapter (eg. Vue, Angular) package.

@@ -65,2 +69,6 @@ Roughly speaking, the usage of skeleton in the template boils down to the following steps:

### `timeOfDay(config: Partial<{ use12HourFormat: boolean; showSeconds: boolean; showAmPm: boolean }> = {})`
Generates a random time of day, using the formatting specified by the `config` parameter.
It can be chained to the `date` method should you wish to further restrict available times (eg. by providing a min and max date to the `date` method that are on the same day within the desired time range).
### `uuid()`

@@ -67,0 +75,0 @@ Increments a global `uuid` variable and sets the current value of the `SchemaItem` instance to this new value.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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