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

contractions

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contractions - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

16

lib/contractions.js

@@ -14,3 +14,9 @@ 'use strict';

keys = Object.keys(this._expandLookup);
keys.sort(function(a, b){ return b.length - a.length; });
keys.sort((a, b) => {
var diff = b.length - a.length;
if (diff !== 0) diff = this._expandLookup[b].length - this._expandLookup[a].length;
return diff;
});
this._expandRegexp = new RegExp(keys.join('|'), 'gi');

@@ -27,3 +33,9 @@

keys = Object.keys(this._contractLookup);
keys.sort(function(a, b){ return b.length - a.length; });
keys.sort((a, b) => {
var diff = b.length - a.length;
if (diff !== 0) diff = this._contractLookup[b].length - this._contractLookup[a].length;
return diff;
});
this._contractRegexp = new RegExp(keys.join('|'), 'gi');

@@ -30,0 +42,0 @@

2

package.json
{
"name": "contractions",
"version": "0.0.4",
"version": "0.0.5",
"licenses": [

@@ -5,0 +5,0 @@ {

@@ -17,9 +17,33 @@ Contractions

````javascript
var Contractions = require('contractions');
var contractions = require('contractions');
console.log(Contractions.expand("I don't know who ya'll are."));
console.log(contractions.expand("I don't know who ya'll are."));
// Outputs: I do not know who you all are.
console.log(Contractions.contract("You all will have not seen this."));
console.log(contractions.contract("You all will have not seen this."));
// Outputs: Y'all'll'ven't seen this.
````
You can also use your own list of contractions / strings.
Note: Longer strings take precedent over short strings.
````javascript
var Contractions = require('contractions').Contractions;
var contractions = new Contractions({
'asap': 'as soon as possible', // only lower case characters should be used in the list
'a.s.a.p.': 'as soon as possible'
});
var text = 'asap';
text = contractions.expand(text);
console.log(text);
// Outputs: as soon as possible
text = contractions.contract(text);
console.log(text);
// Outputs: a.s.a.p.
````
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