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

shave

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shave - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

37

dist/jquery.shave.es.js
/**
shave - Shave is a javascript plugin that truncates multi-line text within a html element based on set max height
@version v4.0.0
@version v5.0.0
@link https://github.com/yowainwright/shave#readme

@@ -8,3 +8,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (jeffry.in)

**/
/*! *****************************************************************************
/******************************************************************************
Copyright (c) Microsoft Corporation.

@@ -71,3 +71,3 @@

}
var _a = opts.character, character = _a === void 0 ? '&mldr;' : _a, _b = opts.classname, classname = _b === void 0 ? 'js-shave' : _b, _c = opts.spaces, initialSpaces = _c === void 0 ? true : _c, _d = opts.charclassname, charclassname = _d === void 0 ? 'js-shave-char' : _d, _e = opts.link, link = _e === void 0 ? {} : _e;
var _a = opts.character, character = _a === void 0 ? '…' : _a, _b = opts.classname, classname = _b === void 0 ? 'js-shave' : _b, _c = opts.spaces, initialSpaces = _c === void 0 ? true : _c, _d = opts.charclassname, charclassname = _d === void 0 ? 'js-shave-char' : _d, _e = opts.link, link = _e === void 0 ? {} : _e;
/**

@@ -89,16 +89,2 @@ * @notes

var shavedTextElType = isLink ? 'a' : 'span';
var textContent = isLink && link.textContent ? link.textContent : character;
var shavedTextEl = document.createElement(shavedTextElType);
var shavedTextElAttributes = {
textContent: textContent,
className: charclassname,
};
for (var property in shavedTextElAttributes) {
shavedTextEl[property] = shavedTextElAttributes[property];
}
if (isLink) {
for (var linkProperty in link) {
shavedTextEl[linkProperty] = link[linkProperty];
}
}
for (var i = 0; i < els.length; i += 1) {

@@ -133,2 +119,17 @@ var el = els[i];

}
var textContent = isLink && link.textContent ? link.textContent : character;
var shavedTextEl = document.createElement(shavedTextElType);
var shavedTextElAttributes = {
className: charclassname,
textContent: textContent,
};
for (var property in shavedTextElAttributes) {
shavedTextEl[property] = shavedTextElAttributes[property];
shavedTextEl.textContent = character;
}
if (isLink) {
for (var linkProperty in link) {
shavedTextEl[linkProperty] = link[linkProperty];
}
}
// Binary search for number of words which can fit in allotted height

@@ -154,3 +155,3 @@ var max = words.length - 1;

var diff = spaces
? " " + words.slice(max).join(' ')
? " ".concat(words.slice(max).join(' '))
: words.slice(max);

@@ -157,0 +158,0 @@ var shavedText = document.createTextNode(diff);

/**
shave - Shave is a javascript plugin that truncates multi-line text within a html element based on set max height
@version v4.0.0
@version v5.0.0
@link https://github.com/yowainwright/shave#readme

@@ -13,3 +13,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (jeffry.in)

/*! *****************************************************************************
/******************************************************************************
Copyright (c) Microsoft Corporation.

@@ -76,3 +76,3 @@

}
var _a = opts.character, character = _a === void 0 ? '&mldr;' : _a, _b = opts.classname, classname = _b === void 0 ? 'js-shave' : _b, _c = opts.spaces, initialSpaces = _c === void 0 ? true : _c, _d = opts.charclassname, charclassname = _d === void 0 ? 'js-shave-char' : _d, _e = opts.link, link = _e === void 0 ? {} : _e;
var _a = opts.character, character = _a === void 0 ? '…' : _a, _b = opts.classname, classname = _b === void 0 ? 'js-shave' : _b, _c = opts.spaces, initialSpaces = _c === void 0 ? true : _c, _d = opts.charclassname, charclassname = _d === void 0 ? 'js-shave-char' : _d, _e = opts.link, link = _e === void 0 ? {} : _e;
/**

@@ -94,16 +94,2 @@ * @notes

var shavedTextElType = isLink ? 'a' : 'span';
var textContent = isLink && link.textContent ? link.textContent : character;
var shavedTextEl = document.createElement(shavedTextElType);
var shavedTextElAttributes = {
textContent: textContent,
className: charclassname,
};
for (var property in shavedTextElAttributes) {
shavedTextEl[property] = shavedTextElAttributes[property];
}
if (isLink) {
for (var linkProperty in link) {
shavedTextEl[linkProperty] = link[linkProperty];
}
}
for (var i = 0; i < els.length; i += 1) {

@@ -138,2 +124,17 @@ var el = els[i];

}
var textContent = isLink && link.textContent ? link.textContent : character;
var shavedTextEl = document.createElement(shavedTextElType);
var shavedTextElAttributes = {
className: charclassname,
textContent: textContent,
};
for (var property in shavedTextElAttributes) {
shavedTextEl[property] = shavedTextElAttributes[property];
shavedTextEl.textContent = character;
}
if (isLink) {
for (var linkProperty in link) {
shavedTextEl[linkProperty] = link[linkProperty];
}
}
// Binary search for number of words which can fit in allotted height

@@ -159,3 +160,3 @@ var max = words.length - 1;

var diff = spaces
? " " + words.slice(max).join(' ')
? " ".concat(words.slice(max).join(' '))
: words.slice(max);

@@ -162,0 +163,0 @@ var shavedText = document.createTextNode(diff);

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

!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";function E(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),a=[];try{for(;(void 0===t||0<t--)&&!(i=o.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a}function S(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;r<o;r++)!i&&r in t||((i=i||Array.prototype.slice.call(t,0,r))[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}function n(e,t,n){if(void 0===n&&(n={}),void 0===t||isNaN(t))throw Error("maxHeight is required");var i="string"==typeof(a=e)?S([],E(document.querySelectorAll(a)),!1):"length"in a?S([],E(a),!1):[a];if(i.length){var r,o=n.character,e=void 0===o?"&mldr;":o,a=n.classname,l=void 0===a?"js-shave":a,o=n.spaces,a=void 0===o||o,o=n.charclassname,c=void 0===o?"js-shave-char":o,n=n.link,s=void 0===n?{}:n,f="boolean"!=typeof a||a,a=s&&"{}"!==JSON.stringify(s)&&s.href,e=a&&s.textContent?s.textContent:e,d=document.createElement(a?"a":"span"),h={textContent:e,className:c};for(r in h)d[r]=h[r];if(a)for(var u in s)d[u]=s[u];for(var v=0;v<i.length;v+=1){var y=i[v],m=y.style,g=y.querySelector("."+l),p=void 0===y.textContent?"innerText":"textContent";g&&(y.removeChild(y.querySelector("."+c)),y[p]=y[p]);var x=y[p],w=f?x.split(" "):x;if(!(w.length<2)){var j=m.height;m.height="auto";var C=m.maxHeight;if(m.maxHeight="none",y.offsetHeight<=t)m.height=j,m.maxHeight=C;else{for(var H,b=w.length-1,A=0;A<b;)H=A+b+1>>1,y[p]=f?w.slice(0,H).join(" "):w.slice(0,H),y.insertAdjacentElement("beforeend",d),y.offsetHeight>t?b=H-1:A=H;y[p]=f?w.slice(0,b).join(" "):w.slice(0,b),y.insertAdjacentElement("beforeend",d);g=f?" "+w.slice(b).join(" "):w.slice(b),x=document.createTextNode(g),g=document.createElement("span");g.classList.add(l),g.style.display="none",g.appendChild(x),y.insertAdjacentElement("beforeend",g),m.height=j,m.maxHeight=C}}}}}var e;"undefined"==typeof window||(e=window.$||window.jQuery||window.Zepto)&&(e.fn.shave=function(e,t){return n(this,e,t),this})});
!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";function N(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,o,r=n.call(e),a=[];try{for(;(void 0===t||0<t--)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function q(e,t,n){if(n||2===arguments.length)for(var i,o=0,r=t.length;o<r;o++)!i&&o in t||((i=i||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}function n(e,t,n){if(void 0===n&&(n={}),void 0===t||isNaN(t))throw Error("maxHeight is required");var i="string"==typeof(e=e)?q([],N(document.querySelectorAll(e)),!1):"length"in e?q([],N(e),!1):[e];if(i.length)for(var e=n.character,o=void 0===e?"…":e,e=n.classname,r=void 0===e?"js-shave":e,e=n.spaces,e=void 0===e||e,a=n.charclassname,l=void 0===a?"js-shave-char":a,a=n.link,c=void 0===a?{}:a,s="boolean"!=typeof e||e,f=c&&"{}"!==JSON.stringify(c)&&c.href,d=f?"a":"span",h=0;h<i.length;h+=1){var u=i[h],v=u.style,y=u.querySelector("."+r),m=void 0===u.textContent?"innerText":"textContent",y=(y&&(u.removeChild(u.querySelector("."+l)),u[m]=u[m]),u[m]),g=s?y.split(" "):y;if(!(g.length<2)){var y=v.height,p=(v.height="auto",v.maxHeight);if(v.maxHeight="none",u.offsetHeight<=t)v.height=y,v.maxHeight=p;else{var x,w=f&&c.textContent?c.textContent:o,j=document.createElement(d),C={className:l,textContent:w};for(x in C)j[x]=C[x],j.textContent=o;if(f)for(var H in c)j[H]=c[H];for(var b,A=g.length-1,E=0;E<A;)b=E+A+1>>1,u[m]=s?g.slice(0,b).join(" "):g.slice(0,b),u.insertAdjacentElement("beforeend",j),u.offsetHeight>t?A=b-1:E=b;u[m]=s?g.slice(0,A).join(" "):g.slice(0,A),u.insertAdjacentElement("beforeend",j);var w=s?" ".concat(g.slice(A).join(" ")):g.slice(A),w=document.createTextNode(w),S=document.createElement("span");S.classList.add(r),S.style.display="none",S.appendChild(w),u.insertAdjacentElement("beforeend",S),v.height=y,v.maxHeight=p}}}}var e;"undefined"!=typeof window&&(e=window.$||window.jQuery||window.Zepto)&&(e.fn.shave=function(e,t){return n(this,e,t),this})});
/**
shave - Shave is a javascript plugin that truncates multi-line text within a html element based on set max height
@version v4.0.0
@version v5.0.0
@link https://github.com/yowainwright/shave#readme

@@ -8,3 +8,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (jeffry.in)

**/
/*! *****************************************************************************
/******************************************************************************
Copyright (c) Microsoft Corporation.

@@ -71,3 +71,3 @@

}
var _a = opts.character, character = _a === void 0 ? '&mldr;' : _a, _b = opts.classname, classname = _b === void 0 ? 'js-shave' : _b, _c = opts.spaces, initialSpaces = _c === void 0 ? true : _c, _d = opts.charclassname, charclassname = _d === void 0 ? 'js-shave-char' : _d, _e = opts.link, link = _e === void 0 ? {} : _e;
var _a = opts.character, character = _a === void 0 ? '…' : _a, _b = opts.classname, classname = _b === void 0 ? 'js-shave' : _b, _c = opts.spaces, initialSpaces = _c === void 0 ? true : _c, _d = opts.charclassname, charclassname = _d === void 0 ? 'js-shave-char' : _d, _e = opts.link, link = _e === void 0 ? {} : _e;
/**

@@ -89,16 +89,2 @@ * @notes

var shavedTextElType = isLink ? 'a' : 'span';
var textContent = isLink && link.textContent ? link.textContent : character;
var shavedTextEl = document.createElement(shavedTextElType);
var shavedTextElAttributes = {
textContent: textContent,
className: charclassname,
};
for (var property in shavedTextElAttributes) {
shavedTextEl[property] = shavedTextElAttributes[property];
}
if (isLink) {
for (var linkProperty in link) {
shavedTextEl[linkProperty] = link[linkProperty];
}
}
for (var i = 0; i < els.length; i += 1) {

@@ -133,2 +119,17 @@ var el = els[i];

}
var textContent = isLink && link.textContent ? link.textContent : character;
var shavedTextEl = document.createElement(shavedTextElType);
var shavedTextElAttributes = {
className: charclassname,
textContent: textContent,
};
for (var property in shavedTextElAttributes) {
shavedTextEl[property] = shavedTextElAttributes[property];
shavedTextEl.textContent = character;
}
if (isLink) {
for (var linkProperty in link) {
shavedTextEl[linkProperty] = link[linkProperty];
}
}
// Binary search for number of words which can fit in allotted height

@@ -154,3 +155,3 @@ var max = words.length - 1;

var diff = spaces
? " " + words.slice(max).join(' ')
? " ".concat(words.slice(max).join(' '))
: words.slice(max);

@@ -157,0 +158,0 @@ var shavedText = document.createTextNode(diff);

/**
shave - Shave is a javascript plugin that truncates multi-line text within a html element based on set max height
@version v4.0.0
@version v5.0.0
@link https://github.com/yowainwright/shave#readme

@@ -14,3 +14,3 @@ @author Jeff Wainwright <yowainwright@gmail.com> (jeffry.in)

/*! *****************************************************************************
/******************************************************************************
Copyright (c) Microsoft Corporation.

@@ -77,3 +77,3 @@

}
var _a = opts.character, character = _a === void 0 ? '&mldr;' : _a, _b = opts.classname, classname = _b === void 0 ? 'js-shave' : _b, _c = opts.spaces, initialSpaces = _c === void 0 ? true : _c, _d = opts.charclassname, charclassname = _d === void 0 ? 'js-shave-char' : _d, _e = opts.link, link = _e === void 0 ? {} : _e;
var _a = opts.character, character = _a === void 0 ? '…' : _a, _b = opts.classname, classname = _b === void 0 ? 'js-shave' : _b, _c = opts.spaces, initialSpaces = _c === void 0 ? true : _c, _d = opts.charclassname, charclassname = _d === void 0 ? 'js-shave-char' : _d, _e = opts.link, link = _e === void 0 ? {} : _e;
/**

@@ -95,16 +95,2 @@ * @notes

var shavedTextElType = isLink ? 'a' : 'span';
var textContent = isLink && link.textContent ? link.textContent : character;
var shavedTextEl = document.createElement(shavedTextElType);
var shavedTextElAttributes = {
textContent: textContent,
className: charclassname,
};
for (var property in shavedTextElAttributes) {
shavedTextEl[property] = shavedTextElAttributes[property];
}
if (isLink) {
for (var linkProperty in link) {
shavedTextEl[linkProperty] = link[linkProperty];
}
}
for (var i = 0; i < els.length; i += 1) {

@@ -139,2 +125,17 @@ var el = els[i];

}
var textContent = isLink && link.textContent ? link.textContent : character;
var shavedTextEl = document.createElement(shavedTextElType);
var shavedTextElAttributes = {
className: charclassname,
textContent: textContent,
};
for (var property in shavedTextElAttributes) {
shavedTextEl[property] = shavedTextElAttributes[property];
shavedTextEl.textContent = character;
}
if (isLink) {
for (var linkProperty in link) {
shavedTextEl[linkProperty] = link[linkProperty];
}
}
// Binary search for number of words which can fit in allotted height

@@ -160,3 +161,3 @@ var max = words.length - 1;

var diff = spaces
? " " + words.slice(max).join(' ')
? " ".concat(words.slice(max).join(' '))
: words.slice(max);

@@ -163,0 +164,0 @@ var shavedText = document.createTextNode(diff);

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).shave=t()}(this,function(){"use strict";function S(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||0<t--)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function N(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||((r=r||Array.prototype.slice.call(t,0,i))[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}return function(e,t,n){if(void 0===n&&(n={}),void 0===t||isNaN(t))throw Error("maxHeight is required");var r="string"==typeof(a=e)?N([],S(document.querySelectorAll(a)),!1):"length"in a?N([],S(a),!1):[a];if(r.length){var i,o=n.character,e=void 0===o?"&mldr;":o,a=n.classname,l=void 0===a?"js-shave":a,o=n.spaces,a=void 0===o||o,o=n.charclassname,s=void 0===o?"js-shave-char":o,n=n.link,c=void 0===n?{}:n,f="boolean"!=typeof a||a,a=c&&"{}"!==JSON.stringify(c)&&c.href,e=a&&c.textContent?c.textContent:e,d=document.createElement(a?"a":"span"),h={textContent:e,className:s};for(i in h)d[i]=h[i];if(a)for(var u in c)d[u]=c[u];for(var v=0;v<r.length;v+=1){var m=r[v],y=m.style,g=m.querySelector("."+l),p=void 0===m.textContent?"innerText":"textContent";g&&(m.removeChild(m.querySelector("."+s)),m[p]=m[p]);var x=m[p],b=f?x.split(" "):x;if(!(b.length<2)){var j=y.height;y.height="auto";var C=y.maxHeight;if(y.maxHeight="none",m.offsetHeight<=t)y.height=j,y.maxHeight=C;else{for(var H,A=b.length-1,E=0;E<A;)H=E+A+1>>1,m[p]=f?b.slice(0,H).join(" "):b.slice(0,H),m.insertAdjacentElement("beforeend",d),m.offsetHeight>t?A=H-1:E=H;m[p]=f?b.slice(0,A).join(" "):b.slice(0,A),m.insertAdjacentElement("beforeend",d);g=f?" "+b.slice(A).join(" "):b.slice(A),x=document.createTextNode(g),g=document.createElement("span");g.classList.add(l),g.style.display="none",g.appendChild(x),m.insertAdjacentElement("beforeend",g),y.height=j,y.maxHeight=C}}}}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).shave=t()}(this,function(){"use strict";function q(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,i,r=n.call(e),a=[];try{for(;(void 0===t||0<t--)&&!(o=r.next()).done;)a.push(o.value)}catch(e){i={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return a}function T(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;i++)!o&&i in t||((o=o||Array.prototype.slice.call(t,0,i))[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}return function(e,t,n){if(void 0===n&&(n={}),void 0===t||isNaN(t))throw Error("maxHeight is required");var o="string"==typeof(e=e)?T([],q(document.querySelectorAll(e)),!1):"length"in e?T([],q(e),!1):[e];if(o.length)for(var i=void 0===(e=n.character)?"…":e,r=void 0===(e=n.classname)?"js-shave":e,e=void 0===(e=n.spaces)||e,a=n.charclassname,l=void 0===a?"js-shave-char":a,c=void 0===(a=n.link)?{}:a,s="boolean"!=typeof e||e,f=c&&"{}"!==JSON.stringify(c)&&c.href,d=f?"a":"span",h=0;h<o.length;h+=1){var u=o[h],v=u.style,y=u.querySelector("."+r),m=void 0===u.textContent?"innerText":"textContent",y=(y&&(u.removeChild(u.querySelector("."+l)),u[m]=u[m]),u[m]),g=s?y.split(" "):y;if(!(g.length<2)){var y=v.height,p=(v.height="auto",v.maxHeight);if(v.maxHeight="none",u.offsetHeight<=t)v.height=y,v.maxHeight=p;else{var x,b=f&&c.textContent?c.textContent:i,j=document.createElement(d),C={className:l,textContent:b};for(x in C)j[x]=C[x],j.textContent=i;if(f)for(var H in c)j[H]=c[H];for(var A,E=g.length-1,S=0;S<E;)A=S+E+1>>1,u[m]=s?g.slice(0,A).join(" "):g.slice(0,A),u.insertAdjacentElement("beforeend",j),u.offsetHeight>t?E=A-1:S=A;u[m]=s?g.slice(0,E).join(" "):g.slice(0,E),u.insertAdjacentElement("beforeend",j);var b=s?" ".concat(g.slice(E).join(" ")):g.slice(E),b=document.createTextNode(b),N=document.createElement("span");N.classList.add(r),N.style.display="none",N.appendChild(b),u.insertAdjacentElement("beforeend",N),v.height=y,v.maxHeight=p}}}}});
{
"name": "shave",
"version": "4.0.0",
"version": "5.0.0",
"description": "Shave is a javascript plugin that truncates multi-line text within a html element based on set max height",

@@ -13,21 +13,25 @@ "main": "dist/shave.js",

],
"types": "types/index.d.ts",
"types": "types/shave.d.ts",
"scripts": {
"build": "rollup -c rollup.config.js && pnpm run build:types",
"build:release": "pnpm run build && pnpm run test",
"build": "pnpm clean && pnpm build:dist && pnpm run build:types",
"build:dist": "rollup -c rollup.config.js",
"build:types": "tsc",
"chore:delete-changelog-branch": "if git show-ref --quiet refs/heads/chore-changelog; then git branch -D chore-changelog; fi",
"chore:branch": "git checkout -b chore-changelog",
"chore:changelog": "conventional-changelog -p eslint -i CHANGELOG.md -s -r 0",
"chore:setup-next-work": "git checkout master && pnpm run chore:delete-changelog-branch",
"chore:pr": "git add . && git commit -m '[chore] updates changelog' --no-verify && git push origin chore-changelog -f",
"chore:setup-changelog": "git checkout master && git pull",
"chore": "pnpm run chore:delete-changelog-branch && pnpm run chore:branch && pnpm run chore:changelog && pnpm run chore:pr && pnpm run chore:setup-next-work",
"clean": "rimraf dist types",
"commit": "git-cz",
"commit-msg": "commitlint --edit $1",
"eslint": "eslint . --fix",
"eslint:ci": "eslint .",
"postpublish": "git tag $npm_package_version && git push origin --tags && pnpm run chore",
"prepush": "pnpm run build && pnpm test && pnpm run eslint:ci",
"format": "prettier --write src/*.ts rollup.config.js tests/*.js scripts/*.js",
"husky-setup": "(path-exists .husky/commit-msg) || (husky install && pnpm husky-setup:commit-msg && pnpm husky-setup:post-merge && pnpm husky-setup:pre-commit)",
"husky-setup:commit-msg": "npx husky add .husky/commit-msg 'pnpm run commit-msg'",
"husky-setup:post-merge": "npx husky add .husky/post-merge 'pnpm run setup'",
"husky-setup:pre-commit": "npx husky add .husky/pre-commit 'pnpm run pre-commit'",
"pre-commit": "pnpm run build && pnpm run test && eslint",
"prepare": "is-ci || pnpm husky-setup",
"prepublishOnly": "pnpm build && pnpm run test",
"setup": "pnpm install --reporter=silent && pnpm build",
"test": "pnpm run test:acceptance && pnpm run test:es-check",
"test:acceptance": "node ./scripts/acceptance.js --coverage",
"test:es-check": "es-check es5 dist/shave.min.js dist/shave.js dist/jquery.shave.js dist/jquery.shave.min.js"
"test:es-check": "es-check es5 dist/shave.min.js dist/shave.js dist/jquery.shave.js dist/jquery.shave.min.js",
"release": "release-it"
},

@@ -59,7 +63,10 @@ "repository": {

"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.0",
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@commitlint/prompt-cli": "^17.0.3",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"@rollup/plugin-typescript": "^8.2.5",
"@types/jquery": "^3.5.6",
"@types/node": "^17.0.0",
"@types/node": "^18.0.0",
"@types/rollup": "^0.54.0",

@@ -69,14 +76,35 @@ "@types/zepto": "^1.0.32",

"@typescript-eslint/parser": "^5.0.0",
"conventional-changelog-cli": "^2.0.11",
"es-check": "6.2.1",
"eslint": "8.10.0",
"eslint": "8.20.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"husky": "^8.0.1",
"is-ci": "^3.0.1",
"node-qunit-phantomjs": "^2.0.0",
"rollup": "^2.45.2",
"path-exists-cli": "^2.0.0",
"prettier": "^2.6.2",
"release-it": "^14.14.3",
"rimraf": "^3.0.2",
"rollup": "^2.77.0",
"rollup-plugin-uglify": "^6.0.1",
"tslib": "^2.3.1",
"typescript": "^4.0.2"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
],
"rules": {
"header-max-length": [
2,
"always",
120
]
}
},
"release-it": {
"github": {
"release": true
}
}
}

@@ -29,9 +29,2 @@ <p align="center">

## V4, Link support
Version `4.0.0` is released with support for links!
There are no official breaking changes, but because html attributes are added differently than in previous versions, the new feature is added as a major release.
Reade more about using `Link` below.
---

@@ -38,0 +31,0 @@

@@ -34,3 +34,3 @@ export type Link = {

const {
character = '&mldr;',
character = '…',
classname = 'js-shave',

@@ -59,19 +59,3 @@ spaces: initialSpaces = true,

const shavedTextElType = isLink ? 'a' : 'span'
const textContent = isLink && link.textContent ? link.textContent : character
const shavedTextEl = document.createElement(shavedTextElType)
const shavedTextElAttributes = {
textContent,
className: charclassname,
}
for (const property in shavedTextElAttributes) {
shavedTextEl[property] = shavedTextElAttributes[property]
}
if (isLink) {
for (const linkProperty in link) {
shavedTextEl[linkProperty] = link[linkProperty]
}
}
for (let i = 0; i < els.length; i += 1) {

@@ -111,2 +95,20 @@ const el = els[i] as HTMLElement

const textContent = isLink && link.textContent ? link.textContent : character
const shavedTextEl = document.createElement(shavedTextElType)
const shavedTextElAttributes = {
className: charclassname,
textContent,
}
for (const property in shavedTextElAttributes) {
shavedTextEl[property] = shavedTextElAttributes[property]
shavedTextEl.textContent = character;
}
if (isLink) {
for (const linkProperty in link) {
shavedTextEl[linkProperty] = link[linkProperty]
}
}
// Binary search for number of words which can fit in allotted height

@@ -113,0 +115,0 @@ let max = words.length - 1

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