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

fuzzyjs

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuzzyjs - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

2

build/fuzzy.js

@@ -117,3 +117,3 @@ 'use strict';

} else {
result += c;
result += originalStr[i];
}

@@ -120,0 +120,0 @@

@@ -1,2 +0,2 @@

"use strict";var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol?"symbol":typeof obj};var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var isArray=function isArray(arr){return Object.prototype.toString.call(arr)==="[object Array]"};var fuzzy={test:function test(q,str){var caseSensitive=arguments.length<=2||arguments[2]===undefined?false:arguments[2];if(typeof q!=="string"||typeof str!=="string"){return-1}if(!str){return-1}if(!q){return true}if(!caseSensitive){q=q.toLowerCase();str=str.toLowerCase()}var pos=0;var i=0;while(i<str.length){if(str[i]===q[pos]){pos+=1}++i}return pos===q.length},match:function match(q,str,opts){if(typeof q!=="string"||typeof str!=="string"){return{score:0,result:str}}if(!str){return{score:0,result:str}}if(!q){return{score:1,result:str}}var originalStr=str;opts=_extends({caseSensitive:false,before:"",after:""},opts);if(!opts.caseSensitive){q=q.toLowerCase();str=str.toLowerCase()}var result="";var steps=0;var pos=0;var lastI=0;var i=0;while(i<str.length){var c=str[i];if(c===q[pos]){result+=opts.before+originalStr[i]+opts.after;pos+=1;steps+=i-lastI;lastI=i}else{result+=c}++i}if(pos===q.length){var score=q.length/(steps+1);return{score:score,result:result}}return{score:0,result:str}},filter:function filter(q,set,opts){if(!isArray(set)){return[]}if(typeof q!=="string"||!q){return set}opts=_extends({caseSensitive:false,before:"",after:""},opts);var results=[];var i=0;while(i<set.length){var str=set[i];var result=fuzzy.match(q,str,opts);if(result.score>0){results.push(result)}++i}return results.sort(function(a,b){return b.score-a.score}).map(function(elem){return elem.result})}};(function(root,factory){if(typeof define==="function"&&define.amd){define([],factory)}else if((typeof module==="undefined"?"undefined":_typeof(module))==="object"&&module.exports){module.exports=factory()}else{root.returnExports=factory()}})(undefined,function(){return fuzzy});
"use strict";var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol?"symbol":typeof obj};var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var isArray=function isArray(arr){return Object.prototype.toString.call(arr)==="[object Array]"};var fuzzy={test:function test(q,str){var caseSensitive=arguments.length<=2||arguments[2]===undefined?false:arguments[2];if(typeof q!=="string"||typeof str!=="string"){return-1}if(!str){return-1}if(!q){return true}if(!caseSensitive){q=q.toLowerCase();str=str.toLowerCase()}var pos=0;var i=0;while(i<str.length){if(str[i]===q[pos]){pos+=1}++i}return pos===q.length},match:function match(q,str,opts){if(typeof q!=="string"||typeof str!=="string"){return{score:0,result:str}}if(!str){return{score:0,result:str}}if(!q){return{score:1,result:str}}var originalStr=str;opts=_extends({caseSensitive:false,before:"",after:""},opts);if(!opts.caseSensitive){q=q.toLowerCase();str=str.toLowerCase()}var result="";var steps=0;var pos=0;var lastI=0;var i=0;while(i<str.length){var c=str[i];if(c===q[pos]){result+=opts.before+originalStr[i]+opts.after;pos+=1;steps+=i-lastI;lastI=i}else{result+=originalStr[i]}++i}if(pos===q.length){var score=q.length/(steps+1);return{score:score,result:result}}return{score:0,result:str}},filter:function filter(q,set,opts){if(!isArray(set)){return[]}if(typeof q!=="string"||!q){return set}opts=_extends({caseSensitive:false,before:"",after:""},opts);var results=[];var i=0;while(i<set.length){var str=set[i];var result=fuzzy.match(q,str,opts);if(result.score>0){results.push(result)}++i}return results.sort(function(a,b){return b.score-a.score}).map(function(elem){return elem.result})}};(function(root,factory){if(typeof define==="function"&&define.amd){define([],factory)}else if((typeof module==="undefined"?"undefined":_typeof(module))==="object"&&module.exports){module.exports=factory()}else{root.returnExports=factory()}})(undefined,function(){return fuzzy});
//# sourceMappingURL=build/fuzzy.min.js.map
{
"name": "fuzzyjs",
"version": "2.1.1",
"version": "2.1.2",
"description": "fuzzyjs is a fuzzy search algorithm in javascript",

@@ -5,0 +5,0 @@ "main": "build/fuzzy.js",

@@ -180,7 +180,7 @@ import assert from 'assert';

it('should keep case when using match (#6)', () => {
const str = 'Foo';
const str = 'FoO';
const q = 'fo';
const expectedScore = 1;
const expectedResult = '<strong>F</strong><strong>o</strong>o';
const expectedResult = '<strong>F</strong><strong>o</strong>O';

@@ -187,0 +187,0 @@ const result = fuzzy.match(q, str, { before: '<strong>', after: '</strong>' });

Sorry, the diff of this file is not supported yet

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