npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

similify

v2.0.2

Published

"Similify is a versatile JavaScript package designed to simplify and enhance similarity comparisons in various contexts. Whether you're comparing words, objects, arrays, or exploring string lengths and numerical ranges, Similify provides an easy-to-use in

Downloads

18

Readme

Similify - a CubeTon Product

npm version License GitHub issues GitHub stars Telegram BB Bot Version

Similify is a versatile JavaScript package designed to simplify and enhance similarity comparisons in various contexts. Whether you're comparing words, objects, arrays, or exploring string lengths and numerical ranges, Similify provides an easy-to-use interface with customizable thresholds. Effortlessly find the most similar instances and match percentages, making complex comparisons a breeze. Streamline your similarity analysis and unlock new possibilities with Similify.

Installation

npm install similify

Usage

Require Similify in your JavaScript file and start using its functions:

Compare Words

const { compareWords } = require('similify');

// Example usage with default threshold (70)
const result = compareWords("apple", "orange");
console.log(result);
// Output: { mostSimilar: 'orange', matchPercentage: 71.43 }  

Word to Object in Array Comparison

const { wordToObjectArrayComparison } = require('similify');

const objectsArray = [{ name: "banana" }, { name: "orange" }];

const result = wordToObjectArrayComparison("apple", objectsArray, "name");
console.log(result);
// Output: { mostSimilar: 'orange', matchPercentage: 71.43 }  

Compare Objects

const { compareObjects } = require('similify');

// Example usage with default threshold (70)
const result = compareObjects({ a: 1, b: 2 }, { a: 1, b: 3 });
console.log(result);
// Output: { mostSimilar: '{"a":1,"b":2}', matchPercentage: 71.43 }  

Compare Array Places

const { compareArrayPlaces } = require('similify');

const array1 = ["apple", "banana"];
const array2 = ["orange", "banana"];

const result = compareArrayPlaces(array1, 0, array2, 1);
console.log(result);
// Output: { mostSimilar: 'banana', matchPercentage: 71.43 }  

Compare Word to Array

const { compareWordToArray } = require('similify');

const word = "apple";
const array = ["orange", "banana", "grape"];

const result = compareWordToArray(word, array);
console.log(result);
// Output: { mostSimilar: 'grape', matchPercentage: 57.14 }  

Compare Arrays

const { compareArrays } = require('similify');

const array1 = ["apple", "banana"];
const array2 = ["orange", "banana", "grape"];

const result = compareArrays(array1, array2);
console.log(result);
// Output: { mostSimilar: ['banana'], matchPercentage: 66.67 }  

Compare String Length

const { compareStringLength } = require('similify');

const result = compareStringLength("apple", "orange");
console.log(result);
// Output: { longerString: 'orange', lengthDifference: 1 }  

Compare Number to Range

const { compareNumberToRange } = require('similify');

const result = compareNumberToRange(25, 20, 30);
console.log(result);
// Output: { withinRange: true, deviationFromMidpoint: 2.5 }  

Below are explanations for each function provided by the Similify package:

compareWords(word1, word2, threshold = 70)

This function compares two words, word1 and word2, by calculating the similarity percentage based on letter matching. The default threshold is set to 70, and the function returns an object with the most similar word and the match percentage.

wordToObjectArrayComparison(word, objectArray, key, threshold = 70)

This function compares a word to the values of a specified key within an array of objects (objectArray). It calculates the similarity percentage for each value and returns an object containing the most similar object instance and the corresponding match percentage.

compareObjects(obj1, obj2, threshold = 70)

Compares two objects (obj1 and obj2) by converting them to JSON strings and then calculating the similarity percentage based on letter matching. The default threshold is set to 70, and the function returns an object with the most similar object and the match percentage.

compareArrayPlaces(array1, index1, array2, index2, threshold = 70)

Compares two elements at specified indices (index1 and index2) within two arrays (array1 and array2). It calculates the similarity percentage based on letter matching and returns an object with the most similar element and the match percentage. The default threshold is set to 70.

compareWordToArray(word, array, threshold = 70)

Compares a word to each element in an array (array). It calculates the similarity percentage for each element and returns an object with the most similar element and the match percentage. The default threshold is set to 70.

compareArrays(array1, array2, threshold = 70)

Compares each element in two arrays (array1 and array2). It calculates the similarity percentage for each pair of elements and returns an object with the most similar elements and the match percentage. The default threshold is set to 70.

compareStringLength(str1, str2)

Compares the lengths of two strings (str1 and str2). It returns an object with the longer string and the absolute difference in length between the two strings.

compareNumberToRange(number, min, max)

Checks if a number is within a specified range (min to max). It returns an object with a boolean indicating whether the number is within the range and the deviation of the number from the midpoint of the range.

These functions provide a variety of comparison functionalities, allowing users to find similarities in words, objects, arrays, string lengths, and numerical ranges. Users can also customize the threshold for similarity based on their specific requirements.

Support

For support and discussions, join our Telegram channel: CubeTon

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.