New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

shave

Package Overview
Dependencies
Maintainers
2
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 0.2.1 to 0.2.2

src/shave.js

10

dist/shave.js

@@ -26,2 +26,4 @@ (function (global, factory) {

var textProp = el.textContent === undefined ? 'innerText' : 'textContent';
// If element text has already been shaved

@@ -31,6 +33,6 @@ if (span) {

el.removeChild(el.querySelector('.js-shave-char'));
el.textContent = el.textContent; // nuke span, recombine text
el[textProp] = el[textProp]; // nuke span, recombine text
}
var fullText = el.textContent;
var fullText = el[textProp];
var words = spaces ? fullText.split(' ') : fullText;

@@ -60,3 +62,3 @@

pivot = min + max + 1 >> 1;
el.textContent = spaces ? words.slice(0, pivot).join(' ') : words.slice(0, pivot);
el[textProp] = spaces ? words.slice(0, pivot).join(' ') : words.slice(0, pivot);
el.insertAdjacentHTML('beforeend', charHtml);

@@ -66,3 +68,3 @@ if (el.offsetHeight > maxHeight) max = spaces ? pivot - 1 : pivot - 2;else min = pivot;

el.textContent = spaces ? words.slice(0, max).join(' ') : words.slice(0, max);
el[textProp] = spaces ? words.slice(0, max).join(' ') : words.slice(0, max);
el.insertAdjacentHTML('beforeend', charHtml);

@@ -69,0 +71,0 @@ var diff = spaces ? words.slice(max + 1).join(' ') : words.slice(max);

4

dist/shave.min.js
/**
* shave - Shave is a javascript plugin that truncates multi-line text within a html element based on set max height
* @version v0.2.0
* @version v0.2.1
* @link https://github.com/dollarshaveclub/shave#readme
* @author Jeff Wainwright <jjwainwright2@gmail.com> (jeffry.in)
* @license ISC */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.shave=t()}(this,function(){"use strict";function e(e,t,n){if(!t)throw Error("maxHeight is required");var s="string"==typeof e?document.querySelectorAll(e):e;"length"in s||(s=[s]);for(var i={character:"…",classname:"js-shave",spaces:!0},a=n&&n.character||i.character,r=n&&n.classname||i.classname,o=(!n||n.spaces!==!1)&&i.spaces,c='<span class="js-shave-char">'+a+"</span>",l=0;l<s.length;l++){var h=s[l],f=h.querySelector("."+r);f&&(h.removeChild(h.querySelector(".js-shave-char")),h.textContent=h.textContent);var d=h.textContent,u=o?d.split(" "):d;if(!(u.length<2)){var y=h.style.height;h.style.height="auto";var p=h.style.maxHeight;if(h.style.maxHeight="none",h.offsetHeight<t)h.style.height=y,h.style.maxHeight=p;else{for(var g=u.length-1,v=0,m=void 0;v<g;)m=v+g+1>>1,h.textContent=o?u.slice(0,m).join(" "):u.slice(0,m),h.insertAdjacentHTML("beforeend",c),h.offsetHeight>t?g=o?m-1:m-2:v=m;h.textContent=o?u.slice(0,g).join(" "):u.slice(0,g),h.insertAdjacentHTML("beforeend",c);var x=o?u.slice(g+1).join(" "):u.slice(g);h.insertAdjacentHTML("beforeend",'<span class="'+r+'" style="display:none;">'+x+"</span>"),h.style.height=y,h.style.maxHeight=p}}}}if("undefined"!=typeof window){var t=window.$||window.jQuery||window.Zepto;t&&(t.fn.shave=function(t,n){return e(this,t,n),this})}return e});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.shave=t()}(this,function(){"use strict";function e(e,t,n){if(!t)throw Error("maxHeight is required");var s="string"==typeof e?document.querySelectorAll(e):e;"length"in s||(s=[s]);for(var i={character:"…",classname:"js-shave",spaces:!0},a=n&&n.character||i.character,r=n&&n.classname||i.classname,o=(!n||n.spaces!==!1)&&i.spaces,c='<span class="js-shave-char">'+a+"</span>",l=0;l<s.length;l++){var h=s[l],f=h.querySelector("."+r),d=void 0===h.textContent?"innerText":"textContent";f&&(h.removeChild(h.querySelector(".js-shave-char")),h[d]=h[d]);var u=h[d],y=o?u.split(" "):u;if(!(y.length<2)){var p=h.style.height;h.style.height="auto";var v=h.style.maxHeight;if(h.style.maxHeight="none",h.offsetHeight<t)h.style.height=p,h.style.maxHeight=v;else{for(var g=y.length-1,m=0,j=void 0;m<g;)j=m+g+1>>1,h[d]=o?y.slice(0,j).join(" "):y.slice(0,j),h.insertAdjacentHTML("beforeend",c),h.offsetHeight>t?g=o?j-1:j-2:m=j;h[d]=o?y.slice(0,g).join(" "):y.slice(0,g),h.insertAdjacentHTML("beforeend",c);var x=o?y.slice(g+1).join(" "):y.slice(g);h.insertAdjacentHTML("beforeend",'<span class="'+r+'" style="display:none;">'+x+"</span>"),h.style.height=p,h.style.maxHeight=v}}}}if("undefined"!=typeof window){var t=window.$||window.jQuery||window.Zepto;t&&(t.fn.shave=function(t,n){return e(this,t,n),this})}return e});
{
"name": "shave",
"version": "0.2.1",
"version": "0.2.2",
"description": "Shave is a javascript plugin that truncates multi-line text within a html element based on set max height",
"main": "dist/shave.js",
"files": [
"dist"
"dist",
"src"
],

@@ -9,0 +10,0 @@ "scripts": {

![shave](http://imgh.us/shave.svg)
[![npm version 0.1.9](https://badge.fury.io/js/shave.svg)](https://www.npmjs.com/package/shave)
[![Bower version 0.1.9](https://badge.fury.io/bo/shave.svg)](https://github.com/dollarshaveclub/shave)
[![npm version 0.2.2](https://badge.fury.io/js/shave.svg)](https://www.npmjs.com/package/shave)
[![Bower version 0.2.2](https://badge.fury.io/bo/shave.svg)](https://github.com/dollarshaveclub/shave)
[![Build Status](https://travis-ci.org/dollarshaveclub/shave.svg?branch=master)](https://travis-ci.org/dollarshaveclub/shave)

@@ -6,0 +6,0 @@ [![Share](https://img.shields.io/twitter/url/http/shields.io.svg?style=social&maxAge=2592000)](https://twitter.com/home?status=Shave%20is%20a%200%20dep%20js%20lib%20that%20truncates%20multiline%20text%20to%20fit%20within%20a%20html%20element%20%E2%9C%81https%3A%2F%2Fgithub.com%2Fdollarshaveclub%2Fshave%20%40DSCEngineering%20%23JavaScript%20%F0%9F%92%AA)

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