Skip to content
This repository was archived by the owner on May 1, 2023. It is now read-only.

Commit 16c348e

Browse files
authored
Merge pull request #15 from aceakash/release-notes
Release notes
2 parents b869c16 + 08ff7bc commit 16c348e

File tree

4 files changed

+52
-55
lines changed

4 files changed

+52
-55
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ string-similarity
33

44
Finds degree of similarity between two strings, based on [Dice's Coefficient](http://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient), which is mostly better than [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_distance).
55

6+
## Table of Contents
7+
8+
* [Usage](#usage)
9+
* [API](#api)
10+
* [compareTwoStrings(string1, string2)](#comparetwostringsstring1-string2)
11+
* [Arguments](#arguments)
12+
* [Returns](#returns)
13+
* [Examples](#examples)
14+
* [findBestMatch(mainString, targetStrings)](#findbestmatchmainstring-targetstrings)
15+
* [Arguments](#arguments-1)
16+
* [Returns](#returns-1)
17+
* [Examples](#examples-1)
18+
* [Release Notes](#release-notes)
19+
* [2.0.0](#200)
20+
21+
622
## Usage
723
Install using:
824

@@ -89,5 +105,12 @@ stringSimilarity.findBestMatch('Olive-green table for sale, in extremely good co
89105
rating: 0.7073170731707317 } }
90106
```
91107

108+
## Release Notes
109+
110+
### 2.0.0
111+
* Removed production dependencies
112+
* Updated to ES6 (this breaks backward-compatibility for pre-ES6 apps)
113+
114+
92115
![Build status](https://codeship.com/projects/2aa453d0-0959-0134-8a76-4abcb29fe9b4/status?branch=master)
93116
[![Known Vulnerabilities](https://snyk.io/test/github/aceakash/string-similarity/badge.svg)](https://snyk.io/test/github/aceakash/string-similarity)

compare-strings.js

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
1-
function flattenDeep (arr) {
2-
return Array.isArray(arr) ? arr.reduce((a, b) => a.concat(flattenDeep(b)) , []) : [arr];
3-
}
4-
5-
function areArgsValid (mainString, targetStrings) {
6-
if (typeof mainString !== 'string') return false;
7-
if (!Array.isArray(targetStrings)) return false;
8-
if (!targetStrings.length) return false;
9-
if (targetStrings.find(s => typeof s !== 'string')) return false;
10-
return true;
11-
}
12-
13-
function letterPairs (str) {
14-
const pairs = [];
15-
for (let i = 0, max = str.length - 1; i < max; i++) pairs[i] = str.substring(i, i + 2);
16-
return pairs;
17-
}
18-
19-
function wordLetterPairs (str) {
20-
const pairs = str.toUpperCase().split(' ').map(letterPairs);
21-
return flattenDeep(pairs);
22-
}
1+
module.exports = {
2+
compareTwoStrings,
3+
findBestMatch
4+
};
235

246
function compareTwoStrings (str1, str2) {
257
if (!str1.length && !str2.length) return 1; // if both are empty strings
@@ -49,8 +31,25 @@ function findBestMatch (mainString, targetStrings) {
4931
return { ratings, bestMatch };
5032
}
5133

34+
function flattenDeep (arr) {
35+
return Array.isArray(arr) ? arr.reduce((a, b) => a.concat(flattenDeep(b)) , []) : [arr];
36+
}
5237

53-
module.exports = {
54-
compareTwoStrings,
55-
findBestMatch
56-
};
38+
function areArgsValid (mainString, targetStrings) {
39+
if (typeof mainString !== 'string') return false;
40+
if (!Array.isArray(targetStrings)) return false;
41+
if (!targetStrings.length) return false;
42+
if (targetStrings.find(s => typeof s !== 'string')) return false;
43+
return true;
44+
}
45+
46+
function letterPairs (str) {
47+
const pairs = [];
48+
for (let i = 0, max = str.length - 1; i < max; i++) pairs[i] = str.substring(i, i + 2);
49+
return pairs;
50+
}
51+
52+
function wordLetterPairs (str) {
53+
const pairs = str.toUpperCase().split(' ').map(letterPairs);
54+
return flattenDeep(pairs);
55+
}

package-lock.json

Lines changed: 3 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "string-similarity",
3-
"version": "1.2.2",
3+
"version": "2.0.0",
44
"description": "Finds degree of similarity between strings, based on Dice's Coefficient, which is mostly better than Levenshtein distance.",
55
"main": "compare-strings.js",
66
"scripts": {

0 commit comments

Comments
 (0)