Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
equivalency
Advanced tools
Equivalency lets you declaratively define rules for string equivalence.
Equivalency works in both Node and browsers back as far as IE 11 (full list of supported browsers).
const checker = require('equivalency');
const { Equivalency } = checker;
// Default rule is byte-equality.
checker.compare('a', 'a');
// { isEquivalent: true }
checker.compare('a', 'A');
// { isEquivalent: false }
// Specify which differences matter/don't matter.
checker.doesntMatter(Equivalency.CAPITALIZATION);
checker.compare('a', 'A');
// { isEquivalent: true }
checker.compare('Hot-dog', 'hotdog');
// { isEquivalent: false }
checker.doesntMatter(Equivalency.en.COMMON_PUNCTUATION);
checker.compare('Hot-dog', 'hotdog');
// { isEquivalent: true }
checker.compare('Go away, fly!', 'Go away; fly!');
// { isEquivalent: true }
checker.matters(',;');
checker.compare('Go away, fly!', 'Go away; fly!');
// { isEquivalent: false }
checker.compare('Go away, fly!', 'Go away; fly!',{giveReasons: true});
// { isEquivalent: false, reasons: [{name: ',;'}] }
// Return edit distance
const options = { calculateEditDistance: true };
checker.compare('show', 'shoe', options);
// { isEquivalent: false, editDistance: 1 }
const esChecker = new Equivalency();
esChecker.compare('adiós', 'adios');
// { isEquivalent: false }
const enChecker = new Equivalency();
enChecker.doesntMatter(Equivalency.ACCENTS);
enChecker.compare('adiós', 'adios');
// { isEquivalent: true }
// Root equivalency: normalizes Unicode, whitespace differences, and case.
const root = new Equivalency()
.doesntMatter(Equivalency.UNICODE_NORMALIZATION)
.doesntMatter(Equivalency.WHITESPACE_DIFFERENCES)
.doesntMatter(Equivalency.CAPITALIZATION)
// Diacritic-blind equivalency cloned from root equivalency.
const equivalencyForDiacriticWarning = root
.clone()
.doesntMatter(Equivalency.COMMON_DIACRITICS);
const isMatch = root.compare(
providedAnswer,
expectedAnswer
).isEquivalent;
const isMatchExceptForDiacritics = equivalencyForDiacriticWarning.compare(
providedAnswer,
expectedAnswer
).isEquivalent;
Equivalency Rules are not applied strictly in the order they are supplied. All map rules are applied, and only then are function rules applied. Therefore, FunctionRules can apply transformations on top of MapRule transformations, but MapRules cannot apply transformations on top of FunctionRules. These two rule types are also applied in fundamentally different ways. MapRules are collapsed into a single map which is then used to transform the comparison strings in a single operation. When two MapRules have conflicting mappings, the mappings in the rule further down the rule chain takes precedence. FunctionRules cascade such that transformation operations are performed individually one after another in the order given.
yarn test
BROWSER_STACK_ACCESS_KEY=<key> yarn run test:karma
See the release doc.
FAQs
Declaratively define rules for string equivalence.
The npm package equivalency receives a total of 130 weekly downloads. As such, equivalency popularity was classified as not popular.
We found that equivalency demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.