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

clipping

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clipping - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

63

lib/clipper.js

@@ -22,10 +22,11 @@ var _ = require('lodash'),

{org: 'about', mod: 'abt', readability: 0.25, type: 'abbreviation'},
{org: 'about', mod: 'abt', readability: 0.25, type: 'abbr'},
{org: 'alcohol', mod: 'alc', readability: 0.75, type: '?'},
{org: 'again', mod: 'agen', readability: 0.25, type: '?'},
{org: 'and', mod: '&', readability: 0.5, type: 'symbol'},
{org: 'are', mod: 'r', readability: 0.6, type: 'sound'},
{org: 'are', mod: 'r', readability: 0.5, type: 'sound'},
{org: 'awkward', mod: 'awk', readability: 0.75, type: '?'},
{org: 'background', mod: 'bgd', readability: 0.3, type: '?'},
{org: 'be', mod: 'b', readability: 0.25, type: 'abbr'},
{org: 'because', mod: 'b/c', readability: 0.5, type: '?'},

@@ -52,2 +53,4 @@ {org: 'before', mod: 'b4', readability: 0.6, type: 'sound'},

{org: 'into', mod: 'in2', readability: 0.5, type: 'sound'},
{org: 'liquor', mod: 'liq', readability: 0.75, type: '?'},

@@ -63,2 +66,3 @@ {org: 'love', mod: 'luv', readability: 0.3, type: '?'},

{org: 'people', mod: 'ppl', readability: 0.75, type: '?'},
{org: 'please', mod: 'pls', readability: 0.75, type: 'abbr'},

@@ -84,3 +88,22 @@ {org: 'obvious', mod: 'obvi', readability: 0.75, type: '?'},

//days of week
{org: 'sunday', mod: 'Su', readability: 0.3, type: 'abbr'},
{org: 'monday', mod: 'Mo', readability: 0.3, type: 'abbr'},
{org: 'tuesday', mod: 'Tu', readability: 0.3, type: 'abbr'},
{org: 'wednesday', mod: 'We', readability: 0.3, type: 'abbr'},
{org: 'thursday', mod: 'Th', readability: 0.3, type: 'abbr'},
{org: 'friday', mod: 'Fr', readability: 0.3, type: 'abbr'},
{org: 'saturday', mod: 'Sa', readability: 0.3, type: 'abbr'},
//months
{org: 'january', mod: 'jan', readability: 0.75, type: 'abbr'},
{org: 'february', mod: 'feb', readability: 0.75, type: 'abbr'},
{org: 'march', mod: 'mar', readability: 0.75, type: 'abbr'},
{org: 'april', mod: 'apr', readability: 0.75, type: 'abbr'},
{org: 'august', mod: 'aug', readability: 0.75, type: 'abbr'},
{org: 'september', mod: 'sept', readability: 0.75, type: 'abbr'},
{org: 'october', mod: 'oct', readability: 0.75, type: 'abbr'},
{org: 'november', mod: 'nov', readability: 0.75, type: 'abbr'},
{org: 'december', mod: 'dec', readability: 0.75, type: 'abbr'},
//TODO: can be modeling?!

@@ -92,9 +115,7 @@

//TODO: months, days of week
//TODO: synonyms
{org: 'hello', mod: 'hi', readability: 0.75, type: 'synonym'},
//TODO: track more than one word
//TODO: synonyms
{org: 'hello', mod: 'hi', readability: 0.75, type: 'synonym'},
//As soon as possible -> asap

@@ -114,13 +135,31 @@ //background -> BR

module.exports = function(text) {
/**
*
* @param text
* @param readability
* @returns {*}
*/
module.exports = function(text, readability) {
readability = readability || 0;
text = text || '';
text = text.replace(regexpForSpaceMarker, markerOfMarkerSymbol);
text = text.replace(/\s/g, ' '+ spaceMarker + ' ');
var tokens = tokenizer.tokenize(text);
return tokens
return tokenizer.tokenize(text)
.map(function(token) {
var alt = words.find({org: token});
if (alt) {
return alt.mod;
var alts = words
.filter({
org: token.toLowerCase()
})
.filter(function(item) {
return item.readability >= readability;
})
.sortBy(function(item) {
return item.mod.length;
});
if (alts.size()) {
return alts.first().mod;
}
return token.trim();

@@ -127,0 +166,0 @@ })

2

package.json
{
"name": "clipping",
"version": "0.1.8",
"version": "0.1.9",
"description": "word clipping",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -21,2 +21,6 @@ var clipper = require('../index'),

});
it('should "For" convert to "4"', function() {
expect(clipper('For')).to.equal('4');
});
});

@@ -39,2 +43,20 @@

});
describe('readability', function() {
it('should use as short as possible version without restrictions on readability', function() {
expect(clipper('love')).to.equal('♥');
});
it('should use as short as possible version if available readability is zero', function() {
expect(clipper('love', 0)).to.equal('♥');
});
it('should use longer version if available readability is .3', function() {
expect(clipper('love', 0.3)).to.equal('luv');
});
it('should keep original version if available readability is more than half', function() {
expect(clipper('love', 0.5)).to.equal('love');
});
});
});
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