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.1.6 to 0.1.7

14

dist/shave.js

@@ -14,6 +14,8 @@ (function (global, factory) {

character: '…',
classname: 'js-shave'
classname: 'js-shave',
spaces: true
};
var character = opts && opts.character || defaults.character;
var classname = opts && opts.classname || defaults.classname;
var spaces = opts && opts.spaces === false ? false : defaults.spaces;
var charHtml = '<span class="js-shave-char">' + character + '</span>';

@@ -36,3 +38,3 @@

var fullText = el.textContent;
var words = fullText.split(' ');
var words = spaces ? fullText.split(' ') : fullText;

@@ -48,10 +50,10 @@ // If 0 or 1 words, we're done

pivot = min + max + 1 >> 1;
el.textContent = words.slice(0, pivot).join(' ');
el.textContent = spaces ? words.slice(0, pivot).join(' ') : words.slice(0, pivot);
el.insertAdjacentHTML('beforeend', charHtml);
if (el.offsetHeight > maxHeight) max = pivot - 1;else min = pivot;
if (el.offsetHeight > maxHeight) max = spaces ? pivot - 1 : pivot - 2;else min = pivot;
}
el.textContent = words.slice(0, max).join(' ');
el.textContent = spaces ? words.slice(0, max).join(' ') : words.slice(0, max);
el.insertAdjacentHTML('beforeend', charHtml);
var diff = words.slice(max + 1).join(' ');
var diff = spaces ? words.slice(max + 1).join(' ') : words.slice(max);

@@ -58,0 +60,0 @@ el.insertAdjacentHTML('beforeend', '<span class="' + classname + '" style="display:none;">' + diff + '</span>');

{
"name": "shave",
"version": "0.1.6",
"version": "0.1.7",
"description": "Shave is a javascript plugin that truncates multi-line text within a html element based on set max height",

@@ -5,0 +5,0 @@ "main": "dist/shave.js",

![shave](http://imgh.us/shave.svg)
[![npm version 0.1.5](https://badge.fury.io/js/shave.svg)](https://www.npmjs.com/package/shave)
[![Bower version 0.1.5](https://badge.fury.io/bo/shave.svg)](https://github.com/dollarshaveclub/shave)
[![npm version 0.1.7](https://badge.fury.io/js/shave.svg)](https://www.npmjs.com/package/shave)
[![Bower version 0.1.7](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)

@@ -19,2 +19,3 @@ [![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)

- is additive. It will play nice with other javascript libraries and more truncation features can easily be built with it.
- supports non-spaced languages ([Non-ascii](https://en.wikipedia.org/wiki/ASCII)).

@@ -65,2 +66,7 @@ ## Installing from a package manager

If you're using a non-spaced language, you can support shave by setting an option `spaces` to `false`.
```javascript
$('selector').shave(maxheight, { classname: 'your-css-class', character: '✁', spaces: false });
```
## Examples

@@ -72,2 +78,4 @@

[Codepen example](http://codepen.io/yowainwright/pen/wzVgMp) with a non-spaced language.
## Notes

@@ -74,0 +82,0 @@

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